6 Replies Latest reply on Feb 17, 2009 10:50 AM by (Herb_Albert)

    LrDialogs.showModalProgressDialog(): does not hide on completion

    Level 1
      In LR 2.3 RC I ran something like:


      LrTasks.startAsyncTask( function()
        LrFunctionContext.callWithContext('function', function(context)

          local progressScope = LrDialogs.showModalProgressDialog({
            title = 'A title',
            caption = 'A caption',
            cannotCancel = true,
            functionContext = context,
          })

          progressScope:setPortionComplete(0.0, 1.0)
          LrTasks.execute(someCmd)
          progressScope:done()

          LrDialogs.presentModalDialog(dialogArgs)

        end)
      end)


      Problem is that the progress dialog is not dismissed on completion. It remains visible (blocked in background) while the next dialog is shown. Same when I set up another function context just for the intended life span of the progress dialog.

      (I now use a "regular" ProgressScope, whose UI entry hides as intended.)

      Herb
        • 1. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
          escouten Adobe Employee
          Hmm ... when I run this code snippet on both Mac and Windows, the dialog does go away as expected.
          • 2. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
            Level 1
            I am sorry, I forgot to mention the platforms. I tested it on Windows 7 Build 7000 + LR 2.3RC as well as on Windows XP + LR 2.1.

            This time I ran the code isolated, same result, this is the complete code I used:

            Info.lua

            return {
            

            LrSdkVersion = 2.0,
            LrSdkMinimumVersion = 2.0, -- minimum SDK version required by this plug-in

            LrPluginName = 'ModalProgressDialogSample',
            LrToolkitIdentifier = 'ns.ModalProgressDialogSample',

            LrExportMenuItems = {
              title = "ModalProgressDialogSample Test",
              file = "MenuItem.lua",
            },
            LrLibraryMenuItems = {
              title = "ModalProgressDialogSample Test",
              file = "MenuItem.lua",
            },
            }



            MenuItem.lua

            local LrTasks = import 'LrTasks'
            
            local LrFunctionContext = import 'LrFunctionContext'
            local LrDialogs = import 'LrDialogs'
            local LrView = import 'LrView'

            local someCmd = '"ping -n 3 localhost"' -- force delay (Windows)

            local dialogArgs = {
              title = 'Another dialog',
              resizable = true,
              contents = LrView.osFactory():static_text { title = 'Progress dialog still visible?' },
              actionVerb = 'sure',
              cancelVerb = 'gone',
            }

            LrTasks.startAsyncTask( function()
              LrFunctionContext.callWithContext('a function', function(aContext)

                local progressScope = LrDialogs.showModalProgressDialog({
                  title = 'Progress',
                  caption = 'Doing some work',
                  cannotCancel = true,
                  functionContext = aContext,
                })

                progressScope:setPortionComplete(0.0, 1.0)
                LrTasks.execute(someCmd)
                progressScope:done()

                LrDialogs.presentModalDialog(dialogArgs)

              end)
            end)
            • 3. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
              escouten Adobe Employee
              Oh OK. I misunderstood you yesterday. I thought the problem was that the progress dialog outlived the function context. Now I see that your concern is that the progress dialog remains visible after the :done() call. It's probably reasonable to expect that, but it isn't how it's implemented now.

              A workaround: You could add another function context to wrap the area where you want the progress dialog to be visible.
              • 4. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
                Level 1
                In my understanding, the API docs say it should disappear: "This dialog remains visible (and blocks the operation of all other Lightroom UI elements) until the progress scope is marked completed or canceled."

                Wrapping within another function context -- that's what I did, but the progress dialog still remains.

                ...
                LrTasks.startAsyncTask( function()
                
                  LrFunctionContext.callWithContext('a function', function(aContext)

                    LrFunctionContext.callWithContext('another function', function(anotherContext)
                      local progressScope = LrDialogs.showModalProgressDialog({
                        title = 'Progress',
                        caption = 'Doing some work',
                        cannotCancel = true,
                        functionContext = anotherContext,
                      })

                      progressScope:setPortionComplete(0.0, 1.0)
                      LrTasks.execute(someCmd)
                      progressScope:done()
                    end)

                    LrDialogs.presentModalDialog(dialogArgs)

                  end)
                end)
                • 5. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
                  escouten Adobe Employee
                  Argh. Looks like there is a task that has to run after the function context unwinds.

                  In the code snippet above, insert a call to LrTasks.sleep(0) immediately in front of your LrDialogs.presentModalDialog call.
                  • 6. Re: LrDialogs.showModalProgressDialog(): does not hide on completion
                    Level 1
                    Jepp, works.

                    I actually tried LrTasks.yield() before in the same manner, but that was when I did not use the second function context so it had no obvious effect...

                    Thanks!