Hi all,
in Partition Manager I stumbled across a multithreading problem that seems to
be related somehow to solid: I try to scan for devices in a separate thread
and show a KProgressDialog in the meantime.
Later on the user might open a file via a KFileDialog. If run as an ordinary
user this works but triggers a number of those:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Solid::Backends::Hal::HalDevice(0x1ee1780), parent's thread is
QThread(0x1ebc9c0), current thread is QThread(0x1d9f470)
For root the KFileDialog gets all upset about dying protocols and becomes
unusable.
The attached test case reproduces the problem. If you swap the deleting of the
thread object and the call to KFileDialog::getOpenFileName, the problem
disappears.
I can probably work around it somehow in Partition Manager, but it still seems
like an issue to be taken seriously to me.
It also seems related to:
http://lists.kde.org/?l=kde-hardware-devel&m=120275510216181
but this just locks up for me and does NOT produce the warnings.
Cheers,
Volker
--
Volker Lanz
http://www.volker-lanz.de
find_package(KDE4 REQUIRED)
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES})
kde4_add_executable(solidthread solidthread.cpp)
target_link_libraries(solidthread ${KDE4_KDECORE_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS})
#include <QThread>
#include <QApplication>
#include <QList>
#include <kfiledialog.h>
#include <solid/device.h>
#include <solid/deviceinterface.h>
#include <solid/storagedrive.h>
class Thread : public QThread
{
public:
void run()
{
const QList<Solid::Device> driveList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive, QString());
foreach(const Solid::Device& solidDevice, driveList)
const Solid::StorageDrive* solidDrive = solidDevice.as<Solid::StorageDrive>();
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Thread* t = new Thread();
t->start();
t->wait();
KFileDialog::getOpenFileName();
delete t;
return 0;
}
_______________________________________________
Kde-hardware-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-hardware-devel