Skip to content

fix(macx): crash in showFullScreen when QScreen is null + window jumping desktops#1503

Open
raul-herreros wants to merge 1 commit into
OpenBoard-org:masterfrom
raul-herreros:fix/macos-showfullscreen-crash
Open

fix(macx): crash in showFullScreen when QScreen is null + window jumping desktops#1503
raul-herreros wants to merge 1 commit into
OpenBoard-org:masterfrom
raul-herreros:fix/macos-showfullscreen-crash

Conversation

@raul-herreros

Copy link
Copy Markdown

Problem

When switching between Document mode and Board mode (e.g., double-clicking a page thumbnail), OpenBoard crashes with a SIGSEGV (EXC_BAD_ACCESS at address 0x8) 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 return nullptr in 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

Thread 0 Crashed:: CrBrowserMain
0   QtGui   QScreen::geometry() const + 0
1   OpenBoard   UBPlatformUtils::showFullScreen(QWidget*) + 168 (UBPlatformUtils_mac.mm:639)
2   OpenBoard   UBApplicationController::showBoard() + 136 (UBApplicationController.cpp:386)
3   OpenBoard   UBDocumentController::thumbnailPageDoubleClicked(...)

Fix

  • Null-safety: Added a fallback chain for screen resolution: pWidget->screen()QGuiApplication::screenAt()QGuiApplication::primaryScreen(), with early return if all fail.
  • Replaced showMaximized() with showNormal() + setGeometry(screen->geometry()) to avoid macOS window manager interference (no more window jumping to different desktops/Spaces).
  • Added raise() + activateWindow() to ensure proper window focus.

Testing

  • Tested on macOS Tahoe 26.5.1 (Apple Silicon) with Qt 6.11.1
  • Verified switching between Document ↔ Board ↔ Document no longer crashes
  • Window stays on the correct screen/desktop

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
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.

1 participant