Skip to content

Commit

Permalink
macOS: Work around crash on exit with Qt 6.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpurcell committed Dec 3, 2024
1 parent 2864737 commit e9d8583
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
QVCocoaFunctions::setFullSizeContentView(windowHandle(), false);
#endif

#if defined COCOA_LOADED && QT_VERSION == QT_VERSION_CHECK(6, 8, 1)
// Workaround for QTBUG-131783
QVCocoaFunctions::flushLastInputEvent(windowHandle());
#endif

if (qvApp->isSessionStateSaveRequested())
qvApp->addClosedWindowSessionState(getSessionState(), getLastActivatedTimestamp());

Expand Down
2 changes: 2 additions & 0 deletions src/qvcocoafunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class QVCocoaFunctions

static void closeWindow(QWindow *window);

static void flushLastInputEvent(QWindow *window);

static void setWindowMenu(QMenu *menu);

static void setAlternate(QMenu *menu, int index);
Expand Down
6 changes: 6 additions & 0 deletions src/qvcocoafunctions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ static void fixNativeMenuEccentricities(QMenu *menu, NSMenu *nativeMenu)
[view.window close];
}

void QVCocoaFunctions::flushLastInputEvent(QWindow *window)
{
auto *view = reinterpret_cast<NSView*>(window->winId());
[view touchesCancelledWithEvent:nil];
}

void QVCocoaFunctions::setWindowMenu(QMenu *menu)
{
NSMenu *nativeMenu = menu->toNSMenu();
Expand Down

0 comments on commit e9d8583

Please sign in to comment.