I'm trying to cleanup properly when my plugin is finished running. This worked fine up through LR 3.0, but Im looking into why it's not working now (under 3.6 or 4.0).
I checked the SDK and found that the LrShutdownPlugin states "Ignored in any Lightroom version older than 3.0"
LrDisablePlugin works, but isn't called when Lightroom is being closed.
Does anyone have a solution? The only hack I can come up with is to have some kind of activity timeout, but that's going to be tough to implement with my current architecture...
I don't fully understand the problem yet - is LrShutdownPlugin not being called in Lr4.0?
For me, LrShutdownPlugin just sets a global flag, then that flag is always checked in loops and background tasks...
I haven't specifically checked whether it's working in Lr4.0, or whether the behavior has changed, nor have I noticed any problems specifically having to do with that, although I have had some strange problems that maybe could have to do with that.
I'm pretty sure both LrShutdownPlugin and LrDisablePlugin were introduced
no earlier than LR 3.0 so if your problem is with LR 2.x then these won't
It sounds like you have problems with both LR 3.x and 4.x. I'm assuming the
problem is with shutdown detection rather than certain functions failing to
work during shutdown? Correct? It is possible that certain features may
have difficulty (e.g. writing to the catalog) depending on how late they
are called in the shutdown process. As an extreme example if my task
detected shutdown, slept for 60 seconds then tried to update photo metadata
I'd be surprised if it worked.
Correct- it doesn't appear that the shutdown file is getting called in LR 3.6 or LR 4. I haven't tested prior to that. Now, one thing that I've noticed is tha the SDK currently states that a method gets called, yet what I have (and every example I see) is a file that gets specified. Maybe I should try specifying a method instead...
I started development of the plugin around 3.2, and the shutdown worked fine then. I noticed that it stopped working with 4.0 when I was doing some regression testing, so I started up 3.6 and did some tests with it as well. I stripped down my Shutdown.lua code to nothing more than just a log message, and I never see anything - it appears that shutdown just isn't getting called, even in 3.6.
My issue is that I have to start some executable code in the background, and I'd like to kill it on exit. Using a timeout would be a huge pain because I'd have to worry about re-starting the executable when it's needed. I could
LrShutdownPlugin is supposed to be the name of a .lua file. But it only gets invoked when you hit Reload in the Plug-in Manager, not when Lightroom shuts down:
I just verified the same behavior in LR 4.0.
I'm glad someone verified this, as the docs are pretty unclear about the difference (if there is any) on how to use LrShutdownPlugin and LrInitPlugin. One is the name of a script, and the other is a function. Shifting language like this, with a language where functions are first-class objects that can be passed around as params, is a recipe for confusion.
So, LrShutdownPlugin is called when the plugin is shutdown "for any reason". Well, other than the app shutting down. Which sort of makes sense -- we certainly don't want the app to be hung on shutdown because of a bad plugin, possibly one that has some handle to the DB open.
LrShutdownPlugin is called when the plugin is shutdown "for any reason". Well, other than the app shutting down.
But what other reasons are there to call it? Sure, you could call it when the plugin was removed. There's already a disable for when the plugin is disabled. Yes, I suppose you could hang something if your shutdown doesn't return, but that could be the case with any part of the plugin.
A plug-in keeping the app from cyling is particularly bad -- it is the last recourse for users trying to fix intractible problems. Anything that increases the number of force quits is not a good strategy. It is very common to to restrict activity like this on shutdown.
I'm not saying this is on purpose, but it does make sense in an environment where you have to balance convenience (API access by third-parties) with safety. It might just be an oversight on Adobe's part.
LrDisablePlugin is a hook into the plug-in manager to know when the disable button has been activated. This is different from LrShutdownPlugin, which can happen for a variety of reasons, only some of which are user-activated. I suspect that if you made a plug-in that failed sometime after being enabled (say, by hooking into the extras menu and forcing a failure) LrShutdownPlugin might be called as a last resort. If my guess that it is sort of a final block is correct.
I'll add this to the scenarios I'd like to check.
Europe, Middle East and Africa