Skip to content

Fix crash when capturing snapshot with a given size#14251

Merged
magnesj merged 2 commits into
devfrom
bugfix/snapshot-capture-crash
Jun 19, 2026
Merged

Fix crash when capturing snapshot with a given size#14251
magnesj merged 2 commits into
devfrom
bugfix/snapshot-capture-crash

Conversation

@magnesj

@magnesj magnesj commented Jun 19, 2026

Copy link
Copy Markdown
Member

Problem

A regression test crashed with an access violation (null read at 0x0) inside Qt's backing-store blit (QWidgetRepaintManager::bltRect) while capturing a plot snapshot.

Root cause

RimViewWindow::internalCaptureSnapshot calls setFixedSize(width, height) and then immediately widget->render(&painter). setFixedSize() only posts a deferred resize. QWidget::render() then delivers that pending resize synchronously from inside the render call (prepareToRenderactivateChildLayoutsRecursivelysendPendingMoveAndResizeEvents). A child QScrollArea reacts by updating its scrollbars and moving its viewport mid-render (updateScrollBarsvalueChangedQWidget::move), which tries to blit a backing store that does not exist while rendering off-screen → crash.

Fix

Flush the pending resize/move events with QApplication::processEvents() right after setFixedSize(), so the layout settles in the widget's normal state before render() is called. This mirrors the existing QApplication::processEvents() usage already present in the snapshot flow (RicSnapshotAllPlotsToFileFeature.cpp).

@magnesj magnesj requested a review from jonjenssen June 19, 2026 06:26
RimProject::current() can return null while the project is being torn down. Guard the project access in the view-window lookups and valid-comparison-views query with an if-init statement so they return empty instead of dereferencing null.
@magnesj magnesj force-pushed the bugfix/snapshot-capture-crash branch from 7176900 to 3ca6e2d Compare June 19, 2026 13:43
Take the view's dock widget as a parameter instead of discovering it by walking the widget parent chain, so the caller supplies it directly. Also forward declare QImage in RimViewWindow.h instead of including it, and drop now unused includes in RimViewWindow.cpp.
@magnesj magnesj force-pushed the bugfix/snapshot-capture-crash branch from 3ca6e2d to ed21999 Compare June 19, 2026 13:50
@magnesj magnesj merged commit 21d3869 into dev Jun 19, 2026
21 checks passed
@magnesj magnesj deleted the bugfix/snapshot-capture-crash branch June 19, 2026 14:38
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.

2 participants