Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Fix Windows FramelessHelperHookWindowProc crash (#305)
Browse files Browse the repository at this point in the history
Application can crash on Windows in the FramelessHelperHookWindowProc callback if the underlying FramelessQuickHelper* has already been deleted. This protects against that crash by using a QPointer to invalidate the instance if it has been deleted which the callback then guards against.
  • Loading branch information
ollie-dawes authored Oct 29, 2023
1 parent c4a7bc8 commit 46ac2f6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/quick/framelessquickhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void FramelessQuickHelperPrivate::attach()
}

if (!data->callbacks) {
QPointer<QWindow> w = window;
data->callbacks = FramelessCallbacks::create();
data->callbacks->getWindowId = [window]() -> WId { return window->winId(); };
data->callbacks->getWindowFlags = [window]() -> Qt::WindowFlags { return window->flags(); };
Expand All @@ -198,7 +199,7 @@ void FramelessQuickHelperPrivate::attach()
data->callbacks->setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); };
data->callbacks->getWindowState = [window]() -> Qt::WindowState { return window->windowState(); };
data->callbacks->setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); };
data->callbacks->getWindowHandle = [q]() -> QWindow * { return q->window(); };
data->callbacks->getWindowHandle = [w]() -> QWindow * { return w; };
data->callbacks->windowToScreen = [window](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); };
data->callbacks->screenToWindow = [window](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); };
data->callbacks->isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool {
Expand Down

0 comments on commit 46ac2f6

Please sign in to comment.