LrProgressScope from a menu item
Hi,
I've been trying to use the LrProgressScope feature in a function that is called from a menu item, but it's being elusive. It looks as though it's trying to do it's job but nothing is updated.
The outline of the code is this:
LrTasks.startAsyncTask( function()
LrFunctionContext.callWithContext( "showCustomDialog", function( context )
Prog = LrProgressScope( {title = 'Checking for local updates', functionContext = context, } )
Prog:setCancelable(true)
local cat = LrApplication.activeCatalog()
cat:withWriteAccessDo('Do Something', function()
for i,p in ipairs(cat.allPhotos) do
if Prog:isCanceled() then
break
end
-- Do stuff, and then
Prog:setPortionComplete(ProcCount, PhotoCount)
Prog:setCaption(LrPathUtils.leafName(p.path))
LrTasks.yield()
end
end )
Prog:done()
end
end )
end )
I've tried with every possible combination of:
- Create the LrProgressScope inside or outside of the callWithContext function
- Call the entire thing inline or as an LrTask
- Use LrTasks.yield() or not
... and in every case, the progress bar only appears when the entire function returns, showing 100% complete. Interestingly, if I replace the LrTasks.yield() with LrTasks.sleep(0.1), I get an error "attempt to yield across metamethod/c-call boundary".
Am I missing the point somewhere? I'd assumed that I may need to have the function running as an LrTask to allow the main thread to update the display, but even this (not illustrated above) doesn't work. Obviously it does from an Export module, but this is being called from a menu.
Help!
Cheers,
Jim