Repository navigation
frontend: an application quit closes the main window first (Fixes #5406) - #5410
Merged
Merged
Conversation
…ocks, RED (Refs #5406) Three cases in test_close_top_level drive QuitClosesMainWindowFirst (a stub that does nothing) with a main window and 32 floating docks that are not closable, like OBS's main docks: a quit must close the main window and the docks, a refused main window close must cancel the quit, and a quit with a hidden main window must not close it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…5406) Cmd+Q, logoff, shutdown and QCoreApplication::quit() reach OBS as QEvent::Quit. Qt then closes the visible top-level windows in no fixed order and cancels the quit when one refuses. The main docks are not closable, so QDockWidget refuses their close while the main window is visible: a floating main dock that came first cancelled the quit, and OBS stayed open for the rest of the session. QuitClosesMainWindowFirst, installed on the application, closes the main window first. If OBSBasic refuses (a cancelled exit prompt, outputs not ready yet), the quit is cancelled as before. Then Qt closes the main docks in any order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#5406) Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
force-pushed
the
fix/5406-quit-floating-dock
branch
from
November 21, 2026 12:13
26912b5 to
f56a1bb
Compare
vpacher
marked this pull request as ready for review
November 21, 2026 12:15
vpacher
enabled auto-merge
November 21, 2026 12:15
This was referenced Nov 21, 2026
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 #5406.
Problem
Cmd+Q, logoff, shutdown and
QCoreApplication::quit()reach OBS asQEvent::Quit. Qt then closes the visible top-level windows in no fixed order (QApplicationPrivate::tryCloseAllWidgetWindows(), a hash set of widgets) and cancels the quit when one of them refuses its close. The main docks (Scenes, Sources, Audio Mixer, Scene Transitions, Controls) are not closable, andQDockWidget::closeEvent()refuses their close while the main window is visible. When a floating main dock came before the main window, the quit was cancelled,OBSBasic::closeWindow()never ran, and OBS stayed open for the rest of the session: File → Exit and SIGTERM ended in the same refused close. An lldb trace on macOS showed the chain from-[NSApplication terminate:]to the refusedscenesDockclose.Change
QuitClosesMainWindowFirst(frontend/utility/close-top-level.hpp, header-only, Qt Widgets only): an event filter on the application. OnQEvent::Quitit closes the visible main window first, throughCloseTopLevel(), as if the user had closed it (OBSBasic::closeEvent()saves, stops the outputs and may ask). If the main window refuses (a cancelled exit prompt, outputs not ready yet), the quit is cancelled, as Qt cancels it. Then Qt closes the main docks in any order. A hidden main window (minimized to the tray) is left to Qt. The main window is held in aQPointer(OBSBasic deletes itself on close).OBSApp::OBSInit()installs it afterOBSBasic::OBSInit().docs/features.md: one line under Fixed upstream bugs, Scenes and UI.Not in this PR: closing one floating main dock (Cmd+W) is #5408; floating docks that hide while OBS is inactive on macOS are #5409.
Tests
Three cases in
test_close_top_level(no new target or registration): a main window with 32 floating docks that are movable and floatable but not closable, like OBS's main docks.quit_closes_the_main_window_with_floating_main_docks: a quit closes the main window once and all docks.quit_is_cancelled_when_the_main_window_refuses: a refused main window close cancels the quit; the docks stay.quit_with_a_hidden_main_window_closes_nothing_twice: with the main window hidden, the quit does not close it again.RED
51f214ae4(stub filter that does nothing): Linux (Qt 6.11.1, offscreen) 5/5 runs fail the first two cases:quit accepted 0, main window close events 0 (expected 1), main window visible 1, docks still visible 32 of 32, docks closed while the main window was visible 1. Windows (Qt 6.10.1, minimal) 10/10 runs fail. With 32 docks, a dock comes before the main window in Qt's order in nearly every run; a RED run can pass by chance only if the main window comes first.GREEN
2f2e38979: Linux 25/25 runs pass, Windows 10/10, the Qt Frontend Linux lane passes (ci/linux_qt_frontend.py, 30 Qt tests). Test cost: about 0.05 s, peak RSS about 28 MB, no own threads.Tier 2 and Tier 3: not applicable (frontend, no C original).
Real app
macOS 27.2.1 build on Apple silicon with Scenes and Stats floating, Cmd+Q: before the fix, 3 of 3 starts stayed open (the "Closing Dockable Window" notice, then nothing; File → Exit and SIGTERM did nothing). With the fix, 4 of 4 starts quit (
==== Shutting down, 0 memory leaks), and the next start shows Scenes floating.🤖 Generated with Claude Code