Fix crash when capturing snapshot with a given size#14251
Merged
Conversation
jonjenssen
approved these changes
Jun 19, 2026
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.
7176900 to
3ca6e2d
Compare
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.
3ca6e2d to
ed21999
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::internalCaptureSnapshotcallssetFixedSize(width, height)and then immediatelywidget->render(&painter).setFixedSize()only posts a deferred resize.QWidget::render()then delivers that pending resize synchronously from inside the render call (prepareToRender→activateChildLayoutsRecursively→sendPendingMoveAndResizeEvents). A childQScrollAreareacts by updating its scrollbars and moving its viewport mid-render (updateScrollBars→valueChanged→QWidget::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 aftersetFixedSize(), so the layout settles in the widget's normal state beforerender()is called. This mirrors the existingQApplication::processEvents()usage already present in the snapshot flow (RicSnapshotAllPlotsToFileFeature.cpp).