Skip to content

gui: own the default main context while the gui is up - #22146

Draft
da-phil wants to merge 1 commit into
darktable-org:masterfrom
da-phil:pl/own_default_main_context_while_gui_is_up
Draft

da-phil wants to merge 1 commit into
darktable-org:masterfrom
da-phil:pl/own_default_main_context_while_gui_is_up

Conversation

@da-phil

@da-phil da-phil commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

g_main_context_invoke() runs its callback in the calling thread whenever it can acquire the context. During dt_init() the gui thread holds the context only inside dt_gui_process_events(), so Lua and job threads built and reparented widgets in parallel with the main window being assembled, crashing at random during startup.

Acquire the context after gtk_init() and release it before dt_control_shutdown() joins the worker threads.

Speculatively fixes #21996

AppImages for testing: https://github.com/da-phil/darktable/actions/runs/33894515106#artifacts

Disclaimer: this change was co-created with Claude.

g_main_context_invoke() runs its callback in the calling thread whenever
it can acquire the context. During dt_init() the gui thread holds the
context only inside dt_gui_process_events(), so Lua and job threads
built and reparented widgets in parallel with the main window being
assembled, crashing at random during startup.

Acquire the context after gtk_init() and release it before
dt_control_shutdown() joins the worker threads.

Speculatively fixes darktable-org#21996
@da-phil
da-phil marked this pull request as draft September 4, 2026 10:35
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.

Consistent segfaults on starting program (appimage)

1 participant