Skip to content

Fixes crash on pinned window followed by darkroom navigation - #22096

Merged
TurboGit merged 1 commit into
darktable-org:masterfrom
masterpiga:fix_2ndwin_crash
Aug 31, 2026
Merged

Fixes crash on pinned window followed by darkroom navigation#22096
TurboGit merged 1 commit into
darktable-org:masterfrom
masterpiga:fix_2ndwin_crash

Conversation

@masterpiga

Copy link
Copy Markdown
Collaborator

Summary

Fixes a crash that occurs when pinning an image in the second darkroom window and navigating images in the main view, and hardens viewport dimension calculations against division-by-zero during image transitions.

Problem & Root Cause

  1. GtkGesture Signal Signature Mismatch:
    In GTK 3, the GtkGesture::begin and GtkGesture::end signals pass three arguments:
    (GtkGesture *gesture, GdkEventSequence *sequence, gpointer user_data).
    The callback handlers omitted the sequence parameter ((GtkGestureZoom *gesture, gpointer user_data)). For touchpad gestures, GTK emits a NULL sequence; on ARM64, this placed 0x0 into the second argument register (x1), causing the callback to receive dev = NULL. Accessing dev->preview2_pinned (at offset 0xba0 in dt_develop_t) caused an immediate null pointer dereference.
  2. Intermediate Loading State Divisor Checks:
    During image switches while second window callbacks are active, dt_dev_get_processed_size could return 0 for width/height before pipeline nodes are ready. Calling functions (dt_dev_get_zoom_scale, _dev_zoom_move, dt_dev_get_pointer_zoom_pos) did not guard against procw <= 0 or proch <= 0, leading to potential division by zero / inf / NaN.
  3. Viewport Fallback:
    dt_dev_get_processed_size always fell back to darktable.develop->preview_pipe instead of checking port->dev->preview_pipe when dealing with a pinned develop instance.

Changes

  • src/gui/gtk.c:
    • Corrected _pinch_begin and _pinch_end callback signatures to include GdkEventSequence *sequence.
  • src/views/darkroom.c:
    • Added !dev checks across all second-window event callbacks (_second_window_pinch, button pressed/released, pan, mouse moved, touch moved, leave).
  • src/develop/develop.c:
    • Updated dt_dev_get_processed_size fallback to respect port->dev when available.
    • Guarded against procw <= 0, proch <= 0, and scale <= 0.0f in dt_dev_get_zoom_scale, _dev_zoom_move, and dt_dev_get_pointer_zoom_pos / dt_dev_get_pointer_zoom_pos_from_bounds.

Verification seqeuence

  • Open second darkroom window and toggle the pin button on an image.
  • Advance images in the main darkroom view (e.g. with Space / Backspace).
  • Zoom and pan in both the main view and the pinned second window using touchpad pinch, wheel scroll, and drag.
  • Unpin and verify normal second window synchronization.

Crash report

crash_report.txt

Co-authored with Gemini.

@masterpiga masterpiga added this to the 5.8 milestone Aug 31, 2026
@masterpiga masterpiga added bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes difficulty: average some changes across different parts of the code base scope: UI user interface and interactions labels Aug 31, 2026

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit
TurboGit merged commit f17ed62 into darktable-org:master Aug 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug difficulty: average some changes across different parts of the code base priority: high core features are broken and not usable at all, software crashes scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants