Fix crash on teardown with Applet's ConfigLoader

Summary:
Deleting AppletPrivate will delete the ConfigLoader which will cause a
save, which can trigger a configSaved signal.

I think it is correct that the config might emit a signal just before
closing, and not at fault.

AppletPrivate is deleted by this point, but Applet is not so the
connection is still alive.

When we handle the signal, it goes into a Q_PRIVATE_SLOT that crashes.

This disconnect pattern is already used for guarding self config
changes.

BUG: 411221

Test Plan: kquitapp5 plasmashell, no longer crashes

Reviewers: #plasma, alexeymin

Reviewed By: alexeymin

Subscribers: alexeymin, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D23707
This commit is contained in:
David Edmundson 2019-09-07 23:19:03 +02:00
parent 9d6a24a771
commit 5f746ce1c2

View File

@ -141,6 +141,10 @@ Applet::~Applet()
//let people know that i will die
emit appletDeleted(this);
// ConfigLoader is deleted when AppletPrivate closes not Applet
// It saves on closure and emits a signal.
// disconnect early to avoid a crash. See 411221
disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged()));
delete d;
}