Am Montag, 30. Januar 2017, 12:34:19 CET schrieb René Seindal: > On 2017-01-30 12:28, Tobias Ellinghaus wrote: > > Am Montag, 30. Januar 2017, 12:04:03 CET schrieb René Seindal: > >> Hi > >> > >> Ho do I make a long running Lua extension not block the darktable GUI? > > > > It depends on what your code does and from where it is called. Some things > > have to run in the gui thread and can't be unblocked, others can. > > > >> When you export files the export runs in the background somehow. > > > > Exports are an example of what gets run in its own thread. So maybe show > > some sample code. > > The code takes the currently selected image in darktable, looks them up > in a shotwell sqlite3 database using luasql and updates ratings and tags > in darktable. > > It is not something that can be handed off to a sub-process since it > updates darktable. > > I have put in a progress bar (background job) but the progress bar > doesn't update and the cancel button doesn't work, because I can't find > a way to hand off control to the gui to update, while looping through > the images, looking stuff up in the other sqlite3 database. > > The script is attached.
Just a general remark: Why do you do that inside darktable with a Lua script instead of a small bash script that just gets all the relevant data from shotwell's database and uses exiftool to create/update XMP files for the images? I think I saw code like that in the past already. Someone even mentioned that shotwell can also write XMP files itself, so maybe all you need is enable that in shotwell and (potentially) rename the XMP files for darktable to recognize them. That being said, I had a look at how other scripts use dt jobs and they handle the cancel callback a little different, see for example https://github.com/darktable-org/lua-scripts/blob/master/contrib/cr2hdr.lua I don't know if that is relevant, maybe Jérémy can chime in? Tobias
signature.asc
Description: This is a digitally signed message part.
