Commit 03b0f4c3 authored by David Edmundson's avatar David Edmundson Committed by Albert Astals Cid
Browse files

[kmainwindow] Don't create native windows for non-toplevel windows

winId() creates a QPlaformWindow; i.e a native xcb_window or wl_surface.
This makes sense for a toplevel which will be a real window.

If someone (in this case localize) uses kmainwindow as a subwidget
inside an existing window the current code will create a subwindow for
this widget. It's a very weird window, as the window is never actually
mapped so all contents are drawn as part of the parent window. Leaving
us in a very corrupt state.

Doing this on XCB is wasteful but the side effects are unnoticed. On
QtWayland things explode in weird ways.

BUG: 424024
parent eceef052
......@@ -347,8 +347,10 @@ void KMainWindowPrivate::polish(KMainWindow *q)
s = objname + s;
if (!q->window()) {
q->winId(); // workaround for setWindowRole() crashing, and set also window role, just in case TT
q->setWindowRole(s); // will keep insisting that object name suddenly should not be used for window role
dbusName = QLatin1Char('/') + QCoreApplication::applicationName() + QLatin1Char('/');
dbusName += q->objectName().replace(QLatin1Char('/'), QLatin1Char('_'));
......@@ -698,7 +700,7 @@ void KMainWindow::applyMainWindowSettings(const KConfigGroup &cg)
const bool oldLetDirtySettings = d->letDirtySettings;
d->letDirtySettings = false;
if (!d->sizeApplied) {
if (!d->sizeApplied && !window()) {
winId(); // ensure there's a window created
KWindowConfig::restoreWindowSize(windowHandle(), cg);
// NOTICE: QWindow::setGeometry() does NOT impact the backing QWidget geometry even if the platform
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment