Commit c0407a38 authored by David Edmundson's avatar David Edmundson
Browse files

Fix test that KMainWindow is a toplevel window

We want to test if there is a parent window and only run some code if we
are a valid toplevel.

!window() covers the case before our window is shown, but after showing
our window() will return ourself as the object when there is no parent.

Fixes 03b0f4c3
Relevant unit tests now pass
parent 03b0f4c3
......@@ -347,7 +347,7 @@ void KMainWindowPrivate::polish(KMainWindow *q)
s = objname + s;
if (!q->window()) {
if (!q->window() || q->window() == q) {
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
......@@ -700,7 +700,7 @@ void KMainWindow::applyMainWindowSettings(const KConfigGroup &cg)
const bool oldLetDirtySettings = d->letDirtySettings;
d->letDirtySettings = false;
if (!d->sizeApplied && !window()) {
if (!d->sizeApplied && (!window() || window() == this)) {
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