Verified Commit 9b8a9dfd authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

powerprofileconfig: Use m_profileCombo as the watcher's parent

`m_profileCombo` could be an invalid pointer, because when clicking an
item, `QAbstractItemView::clicked` and `QAbstractItemView::activated` in
systemsettings both will be emitted, and `IconMode::changeModule` will be
called twice, and `closeModules()` will free `m_profileCombo` in the
second call, which will crash systemsettings.

To fix the crash, set the watcher's parent to `m_profileCombo`, so when
`m_profileCombo` is destroyed, the watcher is also destroyed and the
connection is disconnected to prevent modification to the old `m_profileCombo`.

CCBUG: 443858
parent b801d2b3
Pipeline #113484 passed with stage
in 1 minute and 11 seconds
......@@ -75,7 +75,7 @@ QList<QPair<QString, QWidget *>> PowerProfileConfig::buildUi()
auto *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), this);
auto *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), m_profileCombo);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<QStringList> reply = *watcher;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment