1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-02-01 20:06:53 +01:00

Test we can connect to udisks before connecting signals and reset the pointer of the interface. Thanks mail@holger-mense.de.

This commit is contained in:
David Sansome 2010-12-25 14:25:05 +00:00
parent 843cd92615
commit ced9a8b6e2

View File

@ -47,20 +47,21 @@ void DeviceKitLister::Init() {
OrgFreedesktopUDisksInterface::staticInterfaceName(),
"/org/freedesktop/UDisks", QDBusConnection::systemBus()));
// Listen for changes
connect(interface_.get(), SIGNAL(DeviceAdded(QDBusObjectPath)), SLOT(DBusDeviceAdded(QDBusObjectPath)));
connect(interface_.get(), SIGNAL(DeviceRemoved(QDBusObjectPath)), SLOT(DBusDeviceRemoved(QDBusObjectPath)));
connect(interface_.get(), SIGNAL(DeviceChanged(QDBusObjectPath)), SLOT(DBusDeviceChanged(QDBusObjectPath)));
// Get all the devices currently attached
QDBusPendingReply<QList<QDBusObjectPath> > reply = interface_->EnumerateDevices();
reply.waitForFinished();
if (!reply.isValid()) {
qWarning() << "Error enumerating DeviceKit-disks devices:" << reply.error().name() << reply.error().message();
interface_.reset();
return;
}
// Listen for changes
connect(interface_.get(), SIGNAL(DeviceAdded(QDBusObjectPath)), SLOT(DBusDeviceAdded(QDBusObjectPath)));
connect(interface_.get(), SIGNAL(DeviceRemoved(QDBusObjectPath)), SLOT(DBusDeviceRemoved(QDBusObjectPath)));
connect(interface_.get(), SIGNAL(DeviceChanged(QDBusObjectPath)), SLOT(DBusDeviceChanged(QDBusObjectPath)));
// Get information about each one
QMap<QString, DeviceData> device_data;
foreach (const QDBusObjectPath& path, reply.value()) {