ubuntu-sdk-bugs team mailing list archive
-
ubuntu-sdk-bugs team
-
Mailing list archive
-
Message #07880
[Bug 1776446] Re: QDBusInterface is able to connect to org.freedesktop.DBus, but its status is invalid
I think you should not try to interact with org.freedesktop.DBus
interface directly, instead you should use QDBusConnectionInterface for
that. In your particular case, this would be using
https://doc.qt.io/qt-5/qdbusconnectioninterface.html
#registeredServiceNames-prop:
const QDBusConnectionInterface *iface = QDBusConnection::sessionBus().interface();
QDBusReply<QStringList> servicesReply = iface->registeredServiceNames();
qDebug() << servicesReply.value();
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
** Changed in: qtbase-opensource-src (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
SDK bug tracking, which is subscribed to qtbase-opensource-src in
Ubuntu.
https://bugs.launchpad.net/bugs/1776446
Title:
QDBusInterface is able to connect to org.freedesktop.DBus, but its
status is invalid
Status in qtbase-opensource-src package in Ubuntu:
Invalid
Bug description:
Consider the following example:
#include <QtCore>
#include <QtDBus>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QDBusInterface dbus("org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
QDBusConnection::sessionBus());
if (!dbus.isValid())
{
qDebug() << "IFACE IS NOT VALID" << dbus.lastError().message();
return 1;
}
QDBusReply<QStringList> servicesReply = dbus.call("ListNames");
if (!servicesReply.isValid())
{
qDebug() << "REPLY IS NOT VALID" << servicesReply.error().message();
return 2;
}
qDebug() << servicesReply.value();
}
Compile and run. It prints
IFACE IS NOT VALID ""
The issue here is that QDBusInterface::isValid() returns false,
however it's still possible to call its methods. If I comment out the
"if (!dbus.isValid())" line, it starts to work fine:
#include <QtCore>
#include <QtDBus>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QDBusInterface dbus("org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
QDBusConnection::sessionBus());
/*
if (!dbus.isValid())
{
qDebug() << "IFACE IS NOT VALID" << dbus.lastError().message();
return 1;
}
*/
// WORKS FINE!
QDBusReply<QStringList> servicesReply = dbus.call("ListNames");
if (!servicesReply.isValid())
{
qDebug() << "REPLY IS NOT VALID" << servicesReply.error().message();
return 2;
}
qDebug() << servicesReply.value();
}
In Ubuntu 16.04 it worked fine. All updates have been installed.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qtbase-opensource-src/+bug/1776446/+subscriptions
References