Fix possible crash.

This commit is contained in:
John Preston 2024-01-18 22:21:44 +04:00
parent 30b22ace0b
commit a2c2d92cda

View file

@ -184,14 +184,15 @@ void FixPopupMenuNativeEmojiPopup(not_null<PopupMenu*> menu) {
void SetGeometryWithPossibleScreenChange( void SetGeometryWithPossibleScreenChange(
not_null<QWidget*> widget, not_null<QWidget*> widget,
QRect geometry) { QRect geometry) {
const auto screen = QGuiApplication::screenAt(geometry.center()); if (const auto screen = QGuiApplication::screenAt(geometry.center())) {
const auto window = widget->window(); const auto window = widget->window();
window->createWinId(); window->createWinId();
const auto handle = window->windowHandle(); const auto handle = window->windowHandle();
if (handle->screen() != screen) { if (handle->screen() != screen) {
handle->setScreen(screen); handle->setScreen(screen);
window->move(screen->availableGeometry().topLeft()); window->move(screen->availableGeometry().topLeft());
window->show(); window->show();
}
} }
widget->setGeometry(geometry); widget->setGeometry(geometry);
} }