Skip to content

Commit e16c22c

Browse files
aleixpolximion
authored andcommitted
offline: Fix property invalidation
We'd get a warning every time there's an invalidated property which it's really often. The previous behaviour was incorrect to because invalidations were getting ignored.
1 parent 3b35f2d commit e16c22c

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/offline.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,25 @@ Offline::Action Offline::triggerAction() const
9999
bool Offline::updatePrepared() const
100100
{
101101
Q_D(const Offline);
102-
return d->updatePrepared;
102+
return d->m_properties[QLatin1StringView("UpdatePrepared")];
103103
}
104104

105105
bool Offline::updateTriggered() const
106106
{
107107
Q_D(const Offline);
108-
return d->updateTriggered;
108+
return d->m_properties[QLatin1StringView("UpdateTriggered")];
109109
}
110110

111111
bool Offline::upgradePrepared() const
112112
{
113113
Q_D(const Offline);
114-
return d->upgradePrepared;
114+
return d->m_properties[QLatin1StringView("UpgradePrepared")];
115115
}
116116

117117
bool Offline::upgradeTriggered() const
118118
{
119119
Q_D(const Offline);
120-
return d->upgradeTriggered;
120+
return d->m_properties[QLatin1StringView("UpgradeTriggered")];
121121
}
122122

123123
QDBusPendingReply<> Offline::trigger(Action action)
@@ -249,24 +249,12 @@ void OfflinePrivate::initializeProperties(const QVariantMap &properties)
249249
} else {
250250
triggerAction = Offline::ActionUnset;
251251
}
252-
} else if (property == QLatin1String("UpdatePrepared")) {
253-
updatePrepared = value.toBool();
254-
} else if (property == QLatin1String("UpdateTriggered")) {
255-
updateTriggered = value.toBool();
256-
} else if (property == QLatin1String("UpgradePrepared")) {
257-
upgradePrepared = value.toBool();
258-
} else if (property == QLatin1String("UpgradeTriggered")) {
259-
upgradeTriggered = value.toBool();
260252
} else {
261-
qCWarning(PACKAGEKITQT_OFFLINE) << "Unknown property:" << property << value;
253+
m_properties[property] = value.toBool();
262254
}
263255

264256
++it;
265257
}
266-
267-
if (!properties.isEmpty()) {
268-
q->changed();
269-
}
270258
}
271259

272260
void OfflinePrivate::updateProperties(const QString &interface, const QVariantMap &properties, const QStringList &invalidate)
@@ -276,11 +264,25 @@ void OfflinePrivate::updateProperties(const QString &interface, const QVariantMa
276264
return;
277265
}
278266

279-
if (!invalidate.isEmpty()) {
280-
qCWarning(PACKAGEKITQT_OFFLINE) << "Properties could not be invalidated" << interface << invalidate;
267+
bool invalidations = false;
268+
for (const QString &property : invalidate) {
269+
invalidations = true;
270+
271+
if (property == QLatin1String("PreparedUpgrade")) {
272+
preparedUpgrade.clear();
273+
} else if (property == QLatin1String("TriggerAction")) {
274+
triggerAction = Offline::ActionUnset;
275+
} else {
276+
m_properties.remove(property);
277+
}
281278
}
282279

283280
initializeProperties(properties);
281+
282+
if (invalidations || !properties.isEmpty()) {
283+
Q_Q(Offline);
284+
q->changed();
285+
}
284286
}
285287

286288
#include "moc_offline.cpp"

src/offline_p.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ class OfflinePrivate
4040
OrgFreedesktopPackageKitOfflineInterface iface;
4141
QVariantMap preparedUpgrade;
4242
Offline::Action triggerAction = Offline::ActionUnset;
43-
bool updatePrepared = false;
44-
bool updateTriggered = false;
45-
bool upgradePrepared = false;
46-
bool upgradeTriggered = false;
43+
QMap<QString, bool> m_properties;
4744
};
4845
}
4946

0 commit comments

Comments
 (0)