• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Export plugin - how to stop rendering

Enthusiast ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

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
        end

It 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 ... end

But it makes no difference.

Can this be fixed somehow?
Maybe I'm missing something...

TOPICS
SDK

Views

97

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

correct answers 1 Correct answer

Enthusiast , Jan 18, 2023 Jan 18, 2023

Never mind, I've found the solution.

exportSession should be bound to progressScope and loop should not be terminated with break before iterator called one more time and will actually see progressScope cancellation and will stop exporting.

So this is wrong:

    local progressTitle = "Exporting..."
    local progressScope = LrProgressScope{ title = progressTitle }
    local exportSession = LrExportSession{ photosToExport = photos, exportSettings = settings }
    for _, rendition in exportSession:ren
...

Votes

Translate

Translate
Enthusiast ,
Jan 17, 2023 Jan 17, 2023

Copy link to clipboard

Copied

Another related question (or maybe it's the same) - how to stop exportSession:doExportOnNewTask() early?

The only workarounds I can think of are:

1. create separate exportSession for every photo - looks stupid and seems to be huge performance degrade

2. call exportSession:removePhoto() or rendition:skipRender() on a running exportSession - maybe it will work, but according to documentation should not. it says they should be called before staring iterator.

Neither looks like proper solution to me unfortunately...

Votes

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
Enthusiast ,
Jan 18, 2023 Jan 18, 2023

Copy link to clipboard

Copied

LATEST

Never mind, I've found the solution.

exportSession should be bound to progressScope and loop should not be terminated with break before iterator called one more time and will actually see progressScope cancellation and will stop exporting.

So this is wrong:

    local progressTitle = "Exporting..."
    local progressScope = LrProgressScope{ title = progressTitle }
    local exportSession = LrExportSession{ photosToExport = photos, exportSettings = settings }
    for _, rendition in exportSession:renditions{ progressScope=progressScope,stopIfCanceled=true }
        local success, pathOrMessage = rendition:waitForRender()
        if not success then rendition:uploadFailed(pathOrMessage) end
        LrDialogs.message(tostring(success))
        if progressScope:isCanceled() then exportCancel=true; break; end
    end

With this code export will run in background until fully finished despite the fact that progressScope was cancelled because iterator does not actually saw this cancellation.

 

And this will terminate export if it was canceled as expected:

    local progressTitle = "Exporting..."
    local progressScope = LrProgressScope{ title = progressTitle }
    local exportSession = LrExportSession{ photosToExport = photos, exportSettings = settings }
    for _, rendition in exportSession:renditions{ progressScope=progressScope,stopIfCanceled=true }
        local success, pathOrMessage = rendition:waitForRender()
        if not success then rendition:uploadFailed(pathOrMessage) end
        LrDialogs.message(tostring(success))
    end
    -- set some flag to indicate export cancelation if it's needed
    if progressScope:isCanceled() then exportCancel=true end

 

Hope someone will find this useful one day...

Votes

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