Repository navigation
Fix crash on quit while the Open With menu is being populated - #876
Merged
Merged
Conversation
requestPopulateOpenWithMenu() builds the menu on the global thread pool, and OpenWith::getOpenWithItems() creates QPixmaps there. Quitting while that task is still running destroys the QApplication first; the worker then hits qt_pixmap_thread_test() -> qFatal() and the app aborts. - main(): wait for the global thread pool before the application object is destroyed. - ~MainWindow(): wait for the Open With future, since the task belongs to this window. - Capture the file path by value instead of capturing `this` by reference in the worker lambda. Fixes jurplel#864
The task captures the file path by value and no longer touches the window, so ~MainWindow() doesn't need to wait for it. Waiting froze the GUI for up to a few seconds when a window was closed right after opening an image. main() still waits for the thread pool on quit.
jurplel
approved these changes
Nov 4, 2026
jurplel
left a comment
Owner
There was a problem hiding this comment.
Amazing, thank you for this fix
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.
Fixes #864.
Cause
requestPopulateOpenWithMenu()runsOpenWith::getOpenWithItems()on the global thread pool, and that code createsQPixmaps. If the user quits while this task is still running,~QCoreApplicationruns first and only then waits for the pool. The worker then callsqt_pixmap_thread_test(), which hitsqFatal("QPixmap: Must construct a QGuiApplication before a QPixmap")→SIGABRT.Change
main(): wait forQThreadPool::globalInstance()while the application object still exists.thisby reference, so the task never touches a window that may already be closed.Testing
Tested on macOS 27.0.1 (Apple Silicon). The build was the
7.1tag plus this change and b6ca96c (16/32 px menu icons), against Qt 6.8.3, the version the release bundle ships. The changed code is identical onmain. I did not buildmainlocally.quitApple Event (osascript)I did not check the contents of the Open With menu by eye; the code that builds it is unchanged.
b6ca96c matters here. Without it the Open With task renders every icon size up to 1024 px and takes up to ~3 s. Quitting then waits that long, and macOS delivers a file opened during that time to the exiting instance, so the file is lost.