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
This commit is contained in:
David Edmundson 2018-04-10 14:38:52 +01:00
parent 26d9c50a4b
commit 2785916d01

View File

@ -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();
}