The problem is that std::function is passed by reference instead of
copy, which might become dangling in the finished slot.
(cherry picked from commit
3ed6ee211bbad1f5d76afa1f30844bebad17bed4)
Co-authored-by: Fushan Wen <qydwhotmail@gmail.com>
(cherry picked from commit
995b597b24ca96aaea81f71781de8ddf60adf5e1)
Co-authored-by: Fushan Wen <qydwhotmail@gmail.com>
Gbp-Pq: Name upstream_72719edd_components-sessionprivate-fix-a-potential-crash-in-SessionsModel.patch
}
}
-void SessionsModel::checkScreenLocked(const std::function<void(bool)> &cb)
+void SessionsModel::checkScreenLocked(std::function<void(bool)> &&cb)
{
auto reply = m_screensaverInterface->GetActive();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [cb](QDBusPendingCallWatcher *watcher) {
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [cb = std::move(cb)](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<bool> reply = *watcher;
if (!reply.isError()) {
cb(reply.value());
void aboutToLockScreen();
private:
- void checkScreenLocked(const std::function<void(bool)> &cb);
+ void checkScreenLocked(std::function<void(bool)> &&cb);
KDisplayManager m_displayManager;