Skip to content

fix: autostyle deadlock on import and deprecated API removal for Windows#664

Open
2421468125 wants to merge 1 commit intodarktable-org:masterfrom
2421468125:fix/autostyle-windows-with-deadlock
Open

fix: autostyle deadlock on import and deprecated API removal for Windows#664
2421468125 wants to merge 1 commit intodarktable-org:masterfrom
2421468125:fix/autostyle-windows-with-deadlock

Conversation

@2421468125
Copy link
Copy Markdown

Problems:

  1. Calling darktable.styles.apply() directly inside the post-import-image callback causes darktable to hang/deadlock.

  2. darktable.control.read() has been removed from the Lua API in recent versions (field "read" not found for type dt_lua_singleton_control), causing the script to fail on startup.

  3. Windows cmd.exe only recognizes double quotes while exiftool_attribute() use single quotes for path.

Fix:

  • Wrap the post-import-image callback logic in darktable.control.dispatch() + darktable.control.sleep(500) so that style application runs asynchronously in a background thread after the import pipeline has finished. This avoids the deadlock while still supporting both single-image and batch imports.

  • Remove the darktable.control.read(fd) call from get_stdout(). This function was only used to yield the Lua thread while waiting for I/O — it did not perform any data reading itself (fd:read('*a') handles that). Since the entire exiftool call now runs inside a dispatched background task, blocking the background thread is acceptable and does not freeze the UI.

  • Change path quoting from single to double quotes.

Tested on darktable 5.4.1 / Windows with Canon CR3 files.

Problems:

1. Calling darktable.styles.apply() directly inside the
   post-import-image callback causes darktable to hang/deadlock.

2. darktable.control.read() has been removed from the Lua API in
   recent versions (field "read" not found for type
   dt_lua_singleton_control), causing the script to fail on startup.

3. Windows cmd.exe only recognizes double quotes while exiftool_attribute() use single quotes for path.
Fix:

- Wrap the post-import-image callback logic in
  darktable.control.dispatch() + darktable.control.sleep(500) so that
  style application runs asynchronously in a background thread after
  the import pipeline has finished. This avoids the deadlock while
  still supporting both single-image and batch imports.

- Remove the darktable.control.read(fd) call from get_stdout().
  This function was only used to yield the Lua thread while waiting
  for I/O — it did not perform any data reading itself (fd:read('*a')
  handles that). Since the entire exiftool call now runs inside a
  dispatched background task, blocking the background thread is
  acceptable and does not freeze the UI.

- Changed path quoting from single to double quotes.

Tested on darktable 5.4.1 / Windows with Canon CR3 files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant