QDBusInterface is able to connect to org.freedesktop.DBus, but its status is invalid
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
qtbase-opensource-src (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Consider the following example:
#include <QtCore>
#include <QtDBus>
int main(int argc, char *argv[])
{
QCoreApplic
QDBusInterface dbus("org.
if (!dbus.isValid())
{
qDebug() << "IFACE IS NOT VALID" << dbus.lastError(
return 1;
}
QDBusReply<
if (!servicesReply
{
qDebug() << "REPLY IS NOT VALID" << servicesReply.
return 2;
}
qDebug() << servicesReply.
}
Compile and run. It prints
IFACE IS NOT VALID ""
The issue here is that QDBusInterface:
#include <QtCore>
#include <QtDBus>
int main(int argc, char *argv[])
{
QCoreApplic
QDBusInterface dbus("org.
/*
if (!dbus.isValid())
{
qDebug() << "IFACE IS NOT VALID" << dbus.lastError(
return 1;
}
*/
// WORKS FINE!
QDBusReply<
if (!servicesReply
{
qDebug() << "REPLY IS NOT VALID" << servicesReply.
return 2;
}
qDebug() << servicesReply.
}
In Ubuntu 16.04 it worked fine. All updates have been installed.
I think you should not try to interact with org.freedesktop .DBus interface directly, instead you should use QDBusConnection Interface for that. In your particular case, this would be using https:/ /doc.qt. io/qt-5/ qdbusconnection interface. html#registered ServiceNames- prop:
const QDBusConnection Interface *iface = QDBusConnection ::sessionBus( ).interface( ); QStringList> servicesReply = iface-> registeredServi ceNames( ); value() ;
QDBusReply<
qDebug() << servicesReply.
Any other interface would work fine, org.freedesktop .dbus is blacklisted here: https:/ /code.qt. io/cgit/ qt/qtbase. git/tree/ src/dbus/ qdbusintegrator .cpp?h= 5.9#n2448