diff --git a/shell/shellcorona.h b/shell/shellcorona.h --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -202,7 +202,6 @@ void panelContainmentDestroyed(QObject* cont); void desktopContainmentDestroyed(QObject*); void showOpenGLNotCompatibleWarning(); - void alternativesVisibilityChanged(bool visible); void interactiveConsoleVisibilityChanged(bool visible); void screenRemoved(QScreen* screen); @@ -242,7 +241,6 @@ QMenu *m_addPanelsMenu; KPackage::Package m_lookAndFeelPackage; QSet m_redundantOutputs; - QList m_alternativesObjects; KDeclarative::QmlObject *m_interactiveConsole; QTimer m_waitingPanelsTimer; diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -38,6 +38,8 @@ #include #include #include +#include + #include #include #include @@ -820,42 +822,26 @@ AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj); qmlObj->rootContext()->setContextProperty(QStringLiteral("alternativesHelper"), helper); - m_alternativesObjects << qmlObj; qmlObj->completeInitialization(); - connect(qmlObj->rootObject(), SIGNAL(visibleChanged(bool)), - this, SLOT(alternativesVisibilityChanged(bool))); - connect(applet, &Plasma::Applet::destroyedChanged, this, [this, qmlObj] (bool destroyed) { + auto dialog = qobject_cast(qmlObj->rootObject()); + if (!dialog) { + qWarning() << "Alternatives UI does not inherit from Dialog"; + delete qmlObj; + return; + } + connect(applet, &Plasma::Applet::destroyedChanged, qmlObj, [qmlObj] (bool destroyed) { if (!destroyed) { return; } - QMutableListIterator it(m_alternativesObjects); - while (it.hasNext()) { - KDeclarative::QmlObject *obj = it.next(); - if (obj == qmlObj) { - it.remove(); - obj->deleteLater(); - } - } + qmlObj->deleteLater(); }); -} - -void ShellCorona::alternativesVisibilityChanged(bool visible) -{ - if (visible) { - return; - } - - QObject *root = sender(); - - QMutableListIterator it(m_alternativesObjects); - while (it.hasNext()) { - KDeclarative::QmlObject *obj = it.next(); - if (obj->rootObject() == root) { - it.remove(); - obj->deleteLater(); + connect(dialog, &PlasmaQuick::Dialog::visibleChanged, qmlObj, [qmlObj](bool visible) { + if (visible) { + return; } - } + qmlObj->deleteLater(); + }); } void ShellCorona::unload()