File Dont-alter-memory-management-to-hide-an-item.patch of Package plasma-framework

From 2785916d01b26f5e9747bdf38428adce0a121842 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Tue, 10 Apr 2018 14:38:52 +0100
Subject: Don't alter memory management to hide an item

Summary:
The original owner of a graphics item is the declarative applet script which
is owned and deleted by the applet.

Reparenting the containmentquickitem to the containment doesn't really
solve anything useful, we were originally effectively owned by the
containment(an applet subclass) not the view anyway.

This code also accidentally moves the destruction of the applet from being in
::~Applet to being in ::~QObject of the relevant containment. This
causes a big problem if the AppletQuickItem tries to access the applet
in it's own destructor. The applet object still exists, but use of
Applet member variables is not valid.

The new preloading code does this, leading to a crash.

BUG: 391642

Test Plan:
Changed desktop to folder twice
Changed activities twice

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: rikmills, #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D12064
---
 src/plasmaquick/containmentview.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/plasmaquick/containmentview.cpp b/src/plasmaquick/containmentview.cpp
index 91c81dd..d5a3623 100644
--- a/src/plasmaquick/containmentview.cpp
+++ b/src/plasmaquick/containmentview.cpp
@@ -75,11 +75,8 @@ void ContainmentViewPrivate::setContainment(Plasma::Containment *cont)
     if (containment) {
         QObject::disconnect(containment, 0, q, 0);
         QObject *oldGraphicObject = containment->property("_plasma_graphicObject").value<QObject *>();
-        if (oldGraphicObject) {
-//             qDebug() << "Old graphics Object:" << oldGraphicObject << "Old containment" << containment.data();
-            //make sure the graphic object won't die with us
-            //FIXME:we need a way to reparent to *NO* graphics item, but this makes Qt crash
-            oldGraphicObject->setParent(containment);
+        if (auto item = qobject_cast<QQuickItem*>(oldGraphicObject)) {
+            item->setVisible(false);
         }
         containment->reactToScreenChange();
     }
-- 
cgit v0.11.2

openSUSE Build Service is sponsored by