darktable-org / lua-scripts

155 stars 110 forks source link

register_lib called from the wrong view hangs darktable #278

Closed wpferguson closed 4 years ago

wpferguson commented 4 years ago

If register_lib is called from a script that is in darkroom view, but expecting to be in lighttable view, the script will hang darktable. The opposite is also true, i.e. calling from lighttable view but expecting to be in darkroom view. This is also darktable issue 5884. This becomes a serious issue if you have scripts using register_lib expecting to be started in lighttable view and darktable being started with an image argument, which starts darktable in darkroom view.

This issue can be avoided by testing which view is active before calling register_lib. If the correct view is active, then call register_lib. If not, then register an event for view-changed with a callback to call register lib when the correct view is active.

There are 19 scripts that need fixed. The Lua API documentation also needs updated to add cautions and recommendations to the register_lib section.

To verify this issue:

Change your luarc file to contain require "official/enfuse" Start darktable from the console with darktable -d lua <some image file>

darktable with start and hang. In the console there will be an error message ERROR in lualib, couldn't find a position for enfuse, this should never happen