diff --git a/src/kmessagebox.cpp b/src/kmessagebox.cpp --- a/src/kmessagebox.cpp +++ b/src/kmessagebox.cpp @@ -141,6 +141,10 @@ Q_ASSERT(subWindow); QWindow *mainWindow = QWindow::fromWinId(mainWindowId); + if (!mainWindow) { + // foreign windows not supported on all platforms + return; + } // mainWindow is not the child of any object, so make sure it gets deleted at some point QObject::connect(subWidget, &QObject::destroyed, mainWindow, &QObject::deleteLater); subWindow->setTransientParent(mainWindow);