From 06653433d7a772e50d163df6dc4290e38a2a31dd Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 18 May 2022 09:34:00 +0800 Subject: [PATCH] win32: a little fix Amends commit 8f31e67daed8e298bbcb1e889a0ce4652b095f6e Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/utils_win.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index 1026a64c..8bcabb94 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -556,8 +556,12 @@ void Utils::showSystemMenu(const WId windowId, const QPoint &pos, const bool sel // menu item per menu at most. Set the item ID to "UINT_MAX" (or simply "-1") // can clear the default item for the given menu. SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE); - const int result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() - ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x(), pos.y(), 0, hWnd, nullptr); + const auto result = TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() + ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), pos.x(), pos.y(), 0, hWnd, nullptr); + // The user canceled the menu, no need to continue. + if (result == 0) { + return; + } if (PostMessageW(hWnd, WM_SYSCOMMAND, result, 0) == FALSE) { qWarning() << getSystemErrorMessage(kPostMessageW); }