• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

LrDialogs.runOpenDialog not working inside LrExportServiceProvider

New Here ,
Oct 24, 2022 Oct 24, 2022

Copy link to clipboard

Copied

I am trying to create a Lightroom Classic Export Service Provider plugin that has a Browse... button in the sectionsForTopOfDialog to allow the user to choose a Folder related to the plugin. The open dialog is attached to the action of the viewFactory:push_button, and the dialog opens successfully, but it seems like the rest of the push button's action is never executed, as if the runOpenPanel function never returned.

 

How can I create a Browse button to allow the user to select a folder and get the result? (I want to store the result in the propertyTable, this part is omitted from the code.)

 

Complete plugin code to reproduce the issue below. (Create a folder named runOpenDialogMCVE.lrdevplugin folder, add these files, load it as a Lightroom plugin.)

 

 

-- Info.lua

return {
    LrSdkVersion = 3.0,
    LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plugin

    LrPluginName = "RunOpenPanel MCVE",
    LrToolkitIdentifier = 'com.example.lightroom.runopenpanelmcve',
    
    LrExportServiceProvider = {
        title = "LrDialogs.runOpenPanel MCVE",
        file = 'ExportServiceProvider.lua',
    },

    VERSION = { major=0, minor=1, revision=0 },
}
-- ExportServiceProvider.lua

local LrDialogs = import 'LrDialogs'
local LrLogger = import 'LrLogger'
local LrView = import 'LrView'

local logger = LrLogger("LrDialogs.runOpenDialogMCVE")
local viewFactory = LrView.osFactory()

logger:enable("print")
local ExportServiceProvider = {}

function ExportServiceProvider.sectionsForTopOfDialog( propertyTable )
    
    return {
        {
            title = "LrDialogs.runOpenDialog MCVE",
            viewFactory:row {
                viewFactory:push_button {
                    title = "Browse...",
                    action = function ()
                        logger:trace("Opening dialog...")
                        LrDialogs.message("Will open dialog after this.")
                        local result = LrDialogs.runOpenPanel( {
                            title = "Location",
                            prompt = "Choose",
                            canChooseDirectories = true,
                            canChooseFiles = false,
                            allowsMultipleSelection = false,
                        } )
                        -- I would expect the code below to execute, but it never does.
                        -- No trace is printed and none of the dialogs below are shown.
                        logger.trace("Closing dialog. "..tostring(result))
                        if result ~= nil then
                            logger:trace("Chosen folder: "..result[1])
                            LrDialogs.message("Choseen folder: "..result[1])
                        else
                            logger:trace("Cancelled")
                            LrDialogs.message("Cancelled")
                        end
                    end,
                },
            },
        },
    }
end

return ExportServiceProvider

 

I'm using Lightroom Classic 12.0 on MacOS.

TOPICS
SDK

Views

28

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

LATEST

The problem is this line:

logger.trace("Closing dialog. "..tostring(result))

It should be "logger:trace", not "logger.trace". 

 

There is an error that is raised:

attempt to index field '_actions' (a nil value)
(?: 0)

but for reasons known only to Adobe, errors are often/usually ignored unless they occur in the main task.  That's why you didn't see anything.

 

I recommend you use a debugger, either my lightweight Debugging Toolkit or the Zerobrane IDE.  Both require you to instrument each task and callbacks from the SDK (e.g. the "action" function of buttons).  My toolkit understands LR's unique task implementation and can successfully show stack full stack traces, and it has a full pretty printer for aggregate values. Whereas Zerobrane is a robust, full-featured IDE, but it doesn't fully understand LR's tasks and won't show you full stack traces in some situations.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines