From kde-devel Mon Feb 11 15:54:30 2013 From: Philipp Schmidt Date: Mon, 11 Feb 2013 15:54:30 +0000 To: kde-devel Subject: Problems with Solid in kio-slave (Slots not called, properties not updated) Message-Id: <3487024.3lIyFvrMsx () sam> X-MARC-Message: https://marc.info/?l=kde-devel&m=136059824520321 Hi, I would like my kio_mtp slave to be notified by Solid::DeviceNotifier events. However I can't get the Solid::Devicenotifier to work within my helper thread, as slots apparently can't be called from slave itself. A QTimer::singleShot() works fine. The exact same code, put into a simple QCoreApplication works like a charm. The implementation in the slave constructor is like this: >>>>> ExampleClass *ex = new ExampleClass(); helperThread = new QThread( this ); ex->moveToThread(helperThread); helperThread->start(); <<<<< In the ExampleClass: >>>>> ExampleClass::ExampleClass ( QObject* parent ) { QTimer::singleShot(0, this, SLOT(test())); Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance(); connect( notifier, SIGNAL( deviceAdded(QString) ), this, SLOT(test()) ); connect( notifier, SIGNAL( deviceRemoved(QString) ), this, SLOT(test()) ); } void ExampleClass::test() { kDebug( 7000 ) << "TestTestTest"; } <<<<< The sample project with the code from the top is located at http://dl.dropbox.com/u/14496907/testslave.tar.gz Right now I am retrieving the devices using a foreach loop. >>>>> foreach ( Solid::Device solidDevice, Solid::Device::listFromType( Solid::DeviceInterface::PortableMediaPlayer, QString() ) ) { Solid::GenericInterface *iface = solidDevice.as(); QMap properties = iface->allProperties(); int solidBusNum = properties.value ( QLatin1String ( "BUSNUM" ) ).toInt(); int solidDevNum = properties.value ( QLatin1String ( "DEVNUM" ) ).toInt(); //... } <<<<< However, there the properties are not updated if the device is unplugged und plugged in again (The udi doesn't change, only USB busnum/devnum that LIBMTP uses for identification. So, why is it that Solid won't work in KIO-Slaves like its supposed to? Cheers, Philipp >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<