From a2c2d92cda2cffdafeb671d1f292a2002fb54217 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 18 Jan 2024 22:21:44 +0400 Subject: [PATCH] Fix possible crash. --- ui/platform/win/ui_utility_win.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ui/platform/win/ui_utility_win.cpp b/ui/platform/win/ui_utility_win.cpp index 9ac0e72..30e1e5c 100644 --- a/ui/platform/win/ui_utility_win.cpp +++ b/ui/platform/win/ui_utility_win.cpp @@ -184,14 +184,15 @@ void FixPopupMenuNativeEmojiPopup(not_null menu) { void SetGeometryWithPossibleScreenChange( not_null widget, QRect geometry) { - const auto screen = QGuiApplication::screenAt(geometry.center()); - const auto window = widget->window(); - window->createWinId(); - const auto handle = window->windowHandle(); - if (handle->screen() != screen) { - handle->setScreen(screen); - window->move(screen->availableGeometry().topLeft()); - window->show(); + if (const auto screen = QGuiApplication::screenAt(geometry.center())) { + const auto window = widget->window(); + window->createWinId(); + const auto handle = window->windowHandle(); + if (handle->screen() != screen) { + handle->setScreen(screen); + window->move(screen->availableGeometry().topLeft()); + window->show(); + } } widget->setGeometry(geometry); }