fix(macx): crash in showFullScreen when QScreen is null + window jumping desktops#1503
Open
raul-herreros wants to merge 1 commit into
Open
Conversation
showMaximized() triggers macOS window manager behavior that can relocate the window to a different desktop/Space and fights manual geometry adjustments. The original code also had a null pointer dereference on QScreen (QGuiApplication::screenAt can return nullptr in Qt 6). Changes: - Add null-safety for QScreen with fallback chain: pWidget->screen() -> screenAt() -> primaryScreen() - Replace showMaximized() with showNormal() + setGeometry() to avoid macOS window manager interference - Add raise() + activateWindow() to ensure proper focus - Widget now fullscreens on its current screen without jumping desktops
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
When switching between Document mode and Board mode (e.g., double-clicking a page thumbnail), OpenBoard crashes with a
SIGSEGV(EXC_BAD_ACCESSat address0x8) on macOS with Qt 6.Root Cause
In
UBPlatformUtils::showFullScreen(), the original code calls:QRect currentScreenRect = QGuiApplication::screenAt(pWidget->geometry().topLeft())->geometry();QGuiApplication::screenAt()can returnnullptrin Qt 6 (e.g., when the widget hasn't been fully mapped to a screen yet), and the code dereferences it without a null check, causing the crash.Additionally,
showMaximized()triggers macOS window manager behavior that can relocate the window to a different desktop/Space, causing the app to jump between screens unexpectedly when navigating between views.Crash Stack Trace
Fix
pWidget->screen()→QGuiApplication::screenAt()→QGuiApplication::primaryScreen(), with early return if all fail.showMaximized()withshowNormal()+setGeometry(screen->geometry())to avoid macOS window manager interference (no more window jumping to different desktops/Spaces).raise()+activateWindow()to ensure proper window focus.Testing