[Kde-hardware-devel] multithreading restrictions?

Marcel Wiesweg marcel.wiesweg at gmx.de
Mon Feb 11 19:37:35 CET 2008


> Le Sunday 18 November 2007, Marcel Wiesweg a écrit :
> > I have a bit more for you:
> > For testing, I have added this call to the UI thread, before the worker
> > thread starts.
> >
> > >From the worker thread, when the call is executed again, I then get
> > > about 8 of
> >
> > these error messages:
> >
> > QObject: Cannot create children for a parent that is in a different
> > thread. (Parent is Solid::Backends::Hal::HalDevice(0x83f4f88), parent's
> > thread is QThread(0x82e33f8), current thread is
> > Digikam::ScanController(0x83ddbc0)
>
> Once again, would you mind making a test case for this?

The attached test case is an attempt to isolate the Solid code that was 
causing the problem. The part is copied from digikam source without change. 
With this case, I can reproduce the "Cannot create children for a parent that 
is in a different thread" problem; this is caused when the call is executed 
in two threads at the same time. If you exchange the two lines t.start() and 
t.solid(), then it does not occur.

I have not been able to reproduce the original few-seconds-lockup problem with 
this testcase though. I don't know what is needed to trigger this.
In the meantime, I have worked around the problem by moving the actual Solid 
call to the main thread with a blocking queued signal in digikam, so it's not 
causing trouble at the moment.

>
> I can't seem to reproduce your issues.
>
> Now just curious, why do you use a thread in the first place? If that's
> only for a call to Device::list* that looks like overkill.

It's a worker thread that initializes the database and scans the collection. 
To find out which parts of the collection are available, it needs to know the 
hardware situation. The UI thread is displaying progress info in the time.

Marcel

>
> Regards.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsolid.cpp
Type: text/x-c++src
Size: 3093 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20080211/0262ce21/attachment.bin 
-------------- next part --------------
PROJECT(testsolid)
FIND_PACKAGE(KDE4 REQUIRED)
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )

SET(KDE4ProjectSources testsolid.cpp )

KDE4_ADD_EXECUTABLE(testsolid ${KDE4ProjectSources} )

TARGET_LINK_LIBRARIES(testsolid ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} )


More information about the Kde-hardware-devel mailing list