make sure to cleanup applet pointers on deletion

This commit is contained in:
Marco Martin 2014-08-29 14:53:56 +02:00
parent 727755d28a
commit f934b3b6d6

View File

@ -118,9 +118,7 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const
KService::Ptr service = KService::serviceByDesktopName(application); KService::Ptr service = KService::serviceByDesktopName(application);
if (service || !QStandardPaths::findExecutable(application).isNull() || QFile::exists(application)) { if (service || !QStandardPaths::findExecutable(application).isNull() || QFile::exists(application)) {
d->applicationNames[applet] = application; d->applicationNames[applet] = application;
if (!d->urlLists.contains(applet)) { if (d->urlLists.contains(applet)) {
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*)));
} else {
QAction *a = applet->actions()->action("run associated application"); QAction *a = applet->actions()->action("run associated application");
if (a) { if (a) {
a->setIcon(QIcon::fromTheme("system-run")); a->setIcon(QIcon::fromTheme("system-run"));
@ -128,6 +126,7 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const
} }
} }
} }
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*)));
} }
QString AssociatedApplicationManager::application(const Plasma::Applet *applet) const QString AssociatedApplicationManager::application(const Plasma::Applet *applet) const
@ -152,6 +151,7 @@ void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const QList<Q
} }
} }
} }
connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*)));
} }
//TODO: updateAction slot, called on setting of url or app, and on sycoca change //TODO: updateAction slot, called on setting of url or app, and on sycoca change
QList<QUrl> AssociatedApplicationManager::urls(const Plasma::Applet *applet) const QList<QUrl> AssociatedApplicationManager::urls(const Plasma::Applet *applet) const