Skip to content

Commit

Permalink
offline: Address issues with dbus connections
Browse files Browse the repository at this point in the history
As I added some extra debug information in QtDBus, I realised that
there's a number of connects that were not effective.
This change addresses that by not using the same method for processing
GetAll and the propertiesChanged signal.
  • Loading branch information
aleixpol authored and dantti committed Nov 20, 2022
1 parent 592bb88 commit aeb85b2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/daemonprivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void DaemonPrivate::getAllProperties()
message << PK_OFFLINE_INTERFACE;
QDBusConnection::systemBus().callWithCallback(message,
offline,
SLOT(updateProperties(QVariantMap)));
SLOT(initializeProperties(QVariantMap)));
}

void DaemonPrivate::propertiesChanged(const QString &interface, const QVariantMap &properties, const QStringList &invalidatedProperties)
Expand All @@ -102,7 +102,7 @@ void DaemonPrivate::propertiesChanged(const QString &interface, const QVariantMa
if (interface == PK_NAME) {
updateProperties(properties);
} else if (interface == PK_OFFLINE_INTERFACE) {
offline->d_ptr->updateProperties(properties);
offline->d_ptr->updateProperties(interface, properties, invalidatedProperties);
} else {
qCWarning(PACKAGEKITQT_DAEMON) << "Unknown PackageKit interface:" << interface;
}
Expand Down
18 changes: 16 additions & 2 deletions src/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Offline::Offline(QObject *parent) : QObject(parent)
DBUS_PROPERTIES,
QLatin1String("PropertiesChanged"),
this,
SLOT(propertiesChanged(QString,QVariantMap,QStringList)));
SLOT(updateProperties(QString,QVariantMap,QStringList)));
}

Offline::~Offline()
Expand Down Expand Up @@ -145,7 +145,7 @@ void Offline::getPrepared()
});
}

void OfflinePrivate::updateProperties(const QVariantMap &properties)
void OfflinePrivate::initializeProperties(const QVariantMap &properties)
{
Q_Q(Offline);

Expand Down Expand Up @@ -184,4 +184,18 @@ void OfflinePrivate::updateProperties(const QVariantMap &properties)
}
}

void OfflinePrivate::updateProperties(const QString &interface, const QVariantMap &properties, const QStringList &invalidate)
{
if(interface != PK_OFFLINE_INTERFACE) {
qCWarning(PACKAGEKITQT_OFFLINE) << "Cannot process" << interface << "as" << PK_OFFLINE_INTERFACE;
return;
}

if (!invalidate.isEmpty()) {
qCWarning(PACKAGEKITQT_OFFLINE) << "Properties could not be invalidated" << interface << invalidate;
}

initializeProperties(properties);
}

#include "moc_offline.cpp"
3 changes: 2 additions & 1 deletion src/offline.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class PACKAGEKITQT_LIBRARY Offline : public QObject
explicit Offline(QObject *parent = nullptr);

private:
Q_PRIVATE_SLOT(d_func(), void updateProperties(QVariantMap))
Q_PRIVATE_SLOT(d_func(), void initializeProperties(QVariantMap))
Q_PRIVATE_SLOT(d_func(), void updateProperties(QString, QVariantMap, QStringList))

OfflinePrivate *d_ptr;
};
Expand Down
3 changes: 2 additions & 1 deletion src/offline_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class OfflinePrivate
{
}

void updateProperties(const QVariantMap &properties);
void initializeProperties(const QVariantMap &properties);
void updateProperties(const QString &interface, const QVariantMap &properties, const QStringList &invalidate);

Offline *q_ptr;
OrgFreedesktopPackageKitOfflineInterface iface;
Expand Down

0 comments on commit aeb85b2

Please sign in to comment.