From 9dfefb85dd8a63c9f5332e0250806d8554d4d001 Mon Sep 17 00:00:00 2001 From: Slava Aseev Date: Wed, 8 Dec 2021 17:42:24 +0300 Subject: [PATCH] Fix segfault after toggle the "Show Background" on applet bug: https://bugs.kde.org/show_bug.cgi?id=443317 --- src/quick/items/qquickitem.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp index 67c4611d9e..9625819f83 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2696,8 +2696,16 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this); } } - if (parentWindow) + if (parentWindow) { + if (d->windowRefCount > 0 && d->window != parentWindow) { + qWarning() << + "WORKAROUND: an attempt to reference two different windows. The current implementation " + "cannot handle this situation, so we will be forced to remove the previously referenced window."; + while (d->windowRefCount) + d->derefWindow(); + } d->refWindow(parentWindow); + } } d->dirty(QQuickItemPrivate::ParentChanged); -- 2.33.0