[Applet] Don't crash on remove panel

REVIEW: 127240
CCBUG: 345723

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2016-03-04 21:06:30 +02:00
parent 60af310cfc
commit 6bb02c88eb

View File

@ -292,20 +292,24 @@ void AppletPrivate::askDestroy()
emit q->immutabilityChanged(q->immutability());
if (deleteNotification) {
deleteNotification->close();
}
if (deleteNotificationTimer) {
delete deleteNotificationTimer;
} else if (deleteNotificationTimer) {
deleteNotificationTimer->stop();
deleteNotificationTimer->deleteLater();
deleteNotificationTimer = 0;
}
});
QObject::connect(deleteNotification.data(), &KNotification::closed,
QObject::connect(deleteNotification.data(), &KNotification::closed, q,
[=]() {
//If the timer still exists, it means the undo action was NOT triggered
if (deleteNotificationTimer) {
transient = true;
if (transient) {
emit q->destroyedChanged(true);
cleanUpAndDelete();
}
if (deleteNotificationTimer) {
deleteNotificationTimer->stop();
deleteNotificationTimer->deleteLater();
deleteNotificationTimer = 0;
}
});
deleteNotification->sendEvent();
@ -314,14 +318,15 @@ void AppletPrivate::askDestroy()
//really delete after a minute
deleteNotificationTimer->setInterval(60 * 1000);
deleteNotificationTimer->setSingleShot(true);
QObject::connect(deleteNotificationTimer, &QTimer::timeout,
QObject::connect(deleteNotificationTimer, &QTimer::timeout, q,
[=]() {
transient = true;
if (deleteNotification) {
deleteNotification->close();
} else {
emit q->destroyedChanged(true);
cleanUpAndDelete();
}
transient = true;
emit q->destroyedChanged(true);
cleanUpAndDelete();
});
deleteNotificationTimer->start();
}