Export plugin - how to stop rendering
Hi.
Once again I've faced some strange behaviour with SDK, maybe someone will be able to help.
I'm writing export plugin which should extend exporting capabilities.
In it's processRenderedPhotos() I get a list of photos selected for export, analyzing them and grouping them into groups.
After this each group is exported into different folder.
Because I need to perform multiple exports (one for each group) I can't use exportContext.
If I try to do so LrC shows error "An internal error has occurred: LrExportContext:startRendering: Can't call twice for the same export context"
So I'm using export sessions.
Code looks like this:
local progressTitle = "Exporting..."
local progressScope = LrProgressScope{ title = progressTitle }
local exportSession = LrExportSession{ photosToExport = photos, exportSettings = settings }
for _, rendition in exportSession:renditions() do
local success, pathOrMessage = rendition:waitForRender()
if not success then rendition:uploadFailed(pathOrMessage) end
LrDialogs.message(tostring(success))
if progressScope:isCanceled() then break end
endIt works fine with one huge issue.
If user cancells export by pressing X in the progress bar, loop is actually terminated with break, I don't get message boxes with export results, everything looks fine - plugin's function processRenderedPhotos() is terminated.
But in fact, all the images from this exportSession are still exporting until they all are exported to the destination.
Looks like Lr started exportSession:doExportOnNewTask() and it's running until finishes exporting all photos, or something similar.
And I don't see any way to stop this.
I tried doing:
for _, rendition in exportSession:renditions{ progressScope=progressScope,stopIfCanceled=true } do ... endBut it makes no difference.
Can this be fixed somehow?
Maybe I'm missing something...
