[kcms/virtualdesktops] Properly track synchronizing state
When the user applies a change like adding a desktop DesktopsModel::syncWithServer is called and m_synchronizing is set to true. The server then sends some kind of response (e.g. desktopCreated) and updateModifiedState is called which sets m_synchronizing to false again. However if a setting is changed that does not trigger any server change (e.g. the show OSD setting) m_synchonizing is never set to false again, causing problems down the line. Instead of relying on updateModifiedState to reset m_synchronizing track the syncronizing state by refcounting the DBus calls BUG: 437466
This commit is contained in:
parent
99b84a321a
commit
7f36f01247
2 changed files with 9 additions and 11 deletions
|
@ -37,7 +37,6 @@ DesktopsModel::DesktopsModel(QObject *parent)
|
||||||
, m_serverModified(false)
|
, m_serverModified(false)
|
||||||
, m_serverSideRows(-1)
|
, m_serverSideRows(-1)
|
||||||
, m_rows(-1)
|
, m_rows(-1)
|
||||||
, m_synchronizing(false)
|
|
||||||
{
|
{
|
||||||
qDBusRegisterMetaType<KWin::DBusDesktopDataStruct>();
|
qDBusRegisterMetaType<KWin::DBusDesktopDataStruct>();
|
||||||
qDBusRegisterMetaType<KWin::DBusDesktopDataVector>();
|
qDBusRegisterMetaType<KWin::DBusDesktopDataVector>();
|
||||||
|
@ -239,8 +238,6 @@ void DesktopsModel::setDesktopName(const QString &id, const QString &name)
|
||||||
|
|
||||||
void DesktopsModel::syncWithServer()
|
void DesktopsModel::syncWithServer()
|
||||||
{
|
{
|
||||||
m_synchronizing = true;
|
|
||||||
|
|
||||||
auto callFinished = [this](QDBusPendingCallWatcher *call) {
|
auto callFinished = [this](QDBusPendingCallWatcher *call) {
|
||||||
QDBusPendingReply<void> reply = *call;
|
QDBusPendingReply<void> reply = *call;
|
||||||
|
|
||||||
|
@ -248,6 +245,8 @@ void DesktopsModel::syncWithServer()
|
||||||
handleCallError();
|
handleCallError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--m_pendingCalls;
|
||||||
|
|
||||||
call->deleteLater();
|
call->deleteLater();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,6 +261,7 @@ void DesktopsModel::syncWithServer()
|
||||||
|
|
||||||
call.setArguments({(uint)newIndex, m_names.value(m_desktops.at(newIndex))});
|
call.setArguments({(uint)newIndex, m_names.value(m_desktops.at(newIndex))});
|
||||||
|
|
||||||
|
++m_pendingCalls;
|
||||||
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
||||||
|
|
||||||
const auto *watcher = new QDBusPendingCallWatcher(pending, this);
|
const auto *watcher = new QDBusPendingCallWatcher(pending, this);
|
||||||
|
@ -288,6 +288,7 @@ void DesktopsModel::syncWithServer()
|
||||||
|
|
||||||
call.setArguments({previous});
|
call.setArguments({previous});
|
||||||
|
|
||||||
|
++m_pendingCalls;
|
||||||
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
||||||
|
|
||||||
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
||||||
|
@ -325,6 +326,7 @@ void DesktopsModel::syncWithServer()
|
||||||
|
|
||||||
call.setArguments({i.key(), i.value()});
|
call.setArguments({i.key(), i.value()});
|
||||||
|
|
||||||
|
++m_pendingCalls;
|
||||||
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
||||||
|
|
||||||
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
||||||
|
@ -349,6 +351,7 @@ void DesktopsModel::syncWithServer()
|
||||||
call.setArguments({s_virtualDesktopsInterface,
|
call.setArguments({s_virtualDesktopsInterface,
|
||||||
QStringLiteral("rows"), QVariant::fromValue(QDBusVariant(QVariant((uint)m_rows)))});
|
QStringLiteral("rows"), QVariant::fromValue(QDBusVariant(QVariant((uint)m_rows)))});
|
||||||
|
|
||||||
|
++m_pendingCalls;
|
||||||
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call);
|
||||||
|
|
||||||
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
const QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, this);
|
||||||
|
@ -358,8 +361,6 @@ void DesktopsModel::syncWithServer()
|
||||||
|
|
||||||
void DesktopsModel::reset()
|
void DesktopsModel::reset()
|
||||||
{
|
{
|
||||||
m_synchronizing = false; // Sanity.
|
|
||||||
|
|
||||||
auto getAllAndConnectCall = QDBusMessage::createMethodCall(
|
auto getAllAndConnectCall = QDBusMessage::createMethodCall(
|
||||||
s_serviceName,
|
s_serviceName,
|
||||||
s_virtDesktopsPath,
|
s_virtDesktopsPath,
|
||||||
|
@ -638,10 +639,8 @@ void DesktopsModel::updateModifiedState(bool server)
|
||||||
|
|
||||||
m_serverModified = false;
|
m_serverModified = false;
|
||||||
emit serverModifiedChanged();
|
emit serverModifiedChanged();
|
||||||
|
|
||||||
m_synchronizing = false;
|
|
||||||
} else {
|
} else {
|
||||||
if (m_synchronizing) {
|
if (m_pendingCalls > 0) {
|
||||||
m_serverModified = false;
|
m_serverModified = false;
|
||||||
emit serverModifiedChanged();
|
emit serverModifiedChanged();
|
||||||
|
|
||||||
|
@ -658,8 +657,7 @@ void DesktopsModel::updateModifiedState(bool server)
|
||||||
|
|
||||||
void DesktopsModel::handleCallError()
|
void DesktopsModel::handleCallError()
|
||||||
{
|
{
|
||||||
if (m_synchronizing) {
|
if (m_pendingCalls > 0) {
|
||||||
m_synchronizing = false;
|
|
||||||
|
|
||||||
m_serverModified = false;
|
m_serverModified = false;
|
||||||
emit serverModifiedChanged();
|
emit serverModifiedChanged();
|
||||||
|
|
|
@ -120,7 +120,7 @@ private:
|
||||||
QStringList m_desktops;
|
QStringList m_desktops;
|
||||||
QHash<QString,QString> m_names;
|
QHash<QString,QString> m_names;
|
||||||
int m_rows;
|
int m_rows;
|
||||||
bool m_synchronizing;
|
int m_pendingCalls = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue