Skip to main content
August 18, 2011
Question

publishedPhoto:getPhoto() needs to be called from a task context?

  • August 18, 2011
  • 1 reply
  • 1480 views

Does publishedPhoto:getPhoto() need to be called from a task context? It appears to bail out in an ugly manner if not.

If so, this is really, really inconvenient.

This topic has been closed for replies.

1 reply

areohbee
Legend
August 18, 2011

Just initiate the main function(s) of your plugin in async tasks and it'll make all those kinds of functions happy.

Hint: use flags and cleanup handlers or lr-recursion-guard to keep them from being initiated again before completion.

I use LrFunctionContext.postAsyncTaskWithContext to initiate most main functions, since it offers not only asynchronous execution, but a context for error handling and cleanup which is nearly always a good thing.

Code examples available at: https://www.assembla.com/spaces/lrdevplugin/

(see System/App and System/Call modules).

August 18, 2011

I'm pretty much already doing this, because I'm doing stuff in a menu item. So the main menu item/dialog callback is in an LrFunctionContext.

Something else is at play here. The coroutine stuff in the SDK is a mess.

areohbee
Legend
August 18, 2011

clvrmnky wrote:

I'm pretty much already doing this, because I'm doing stuff in a menu item. So the main menu item/dialog callback is in an LrFunctionContext.

Something else is at play here. The coroutine stuff in the SDK is a mess.

So, the problem was *not* the need for it to be executed in an async task, but was something else?

How is the coroutine stuff a mess?