colorharmonizer: reset histogram validity and auto-detect on image switch - #22214
Conversation
|
RELEASE_NOTES.md update is missing, otherwise the bots are happy; they mentioned one pre-existing low-prio finding, maybe you can address that: "Pre-existing UX issue: when colorharmonizer is disabled, the auto-detect button remains insensitive and its tooltip says to wait for preview processing, although processing will not occur until the module is enabled. This commit does not introduce the behavior; it makes the existing initial state recur correctly after image switches while preventing stale-histogram use." |
29a1216 to
9e7f821
Compare
|
Thanks, @kofa73, both done |
|
You know them bots better than I do... I did not have time to build and test, I guess you have a working copy available.
|
9e7f821 to
3155b29
Compare
…itch Base module instances are retained across darkroom image switches without re-running gui_init(). Because colorharmonizer lacked a change_image() hook, g->histogram_valid remained TRUE and the auto-detect button remained sensitive when loading a new image. Clicking auto-detect before the new preview finished (or when colorharmonizer was disabled on the new image, where the preview pipe never runs process()) evaluated the previous image's hue histogram and committed it to the new image's history, also forcibly enabling the module. In addition, _update_histogram() scheduled an idle callback using the deprecated gdk_threads_add_idle() keyed on the GtkWidget rather than self. This leaked widget references on aborted runs and prevented cancelling pending sources on image transitions or teardown. Fix this protocol: - Implement change_image() to drain pending idle callbacks, reset g->histogram_valid = FALSE, and clear pending auto-detection. - Drain idle callbacks on gui_cleanup() to prevent running on torn down gui_data. - Key idle callbacks on self using g_idle_add(), dropping the redundant widget ref/unref. - Replace private g->histogram_lock with dt_iop_gui_enter_critical_section(), bringing the edge detection and validity checks inside the critical section. - Support on-demand auto-detection: if clicked when the histogram is not yet available, enable the module and defer detection until the preview pipe completes. - Consolidate button sensitivity and tooltip updates into a helper. Fixes darktable-org#22059
3155b29 to
74242bc
Compare
|
I made so that the auto-detect button is always enabled, and if the histogram is not cached yet it first computes and then detects the harmony. |
The problem
Base module instances are retained across darkroom image switches without
re-running
gui_init(). Because colorharmonizer lacked achange_image()hook,
g->histogram_validremainedTRUEand the auto-detect button remainedsensitive when loading a new image. Clicking auto-detect before the new
preview finished (or when colorharmonizer was disabled on the new image,
where the preview pipe never runs
process()) evaluated the previousimage's hue histogram and committed it to the new image's history, also
forcibly enabling the module.
In addition,
_update_histogram()scheduled an idle callback using thedeprecated
gdk_threads_add_idle()keyed on theGtkWidgetrather thanself. This leaked widget references on aborted runs and preventedcancelling pending sources on image transitions or teardown.
The fix
change_image()to drain pending idle callbacks, resetg->histogram_valid = FALSE, and clear pending auto-detection.gui_cleanup()to prevent running on torn downgui_data.
g_idle_add(), dropping the redundantwidget ref/unref.
g->histogram_lockwithdt_iop_gui_enter_critical_section(), bringing the edge detectionand validity checks inside the critical section.
not yet available, enable the module and defer detection until the
preview pipe completes.
Fixes #22059