ThreadWeaver and asyncronous operations
Paulo Moura Guedes
moura at kdewebdev.org
Thu Mar 29 12:48:30 BST 2007
On Wednesday 28 March 2007 22:03, Louai Al-Khanji wrote:
> On Wednesday 28 March 2007 20:19, Paulo Moura Guedes wrote:
> > On Wednesday 28 March 2007 08:25, you wrote:
> > > Hi Paulo,
> > >
> > > the reason is:
> > >
> > > * you create the job in your main thread
> > > * this creates the timer in the main thread
> >
> > I'm not creating any timer in the main thread...
> >
> > > then the job is executed in one of the threads of threadweavers pool
> > >
> > > * this makes the QTimer think it still resides in the main thread, thus
> > > the error message
> > > * you need to create the timer once the job is executed, within the run
> > > function, then it knows about its correct thread
> >
> > The timer is created after calling the async operation in the run()
> > method, so the timer is not created on the the GUI thread.
> > All objects are being created in the run() method or one of its childs
> > with the exception of the job itself, like you said.
> > I can't understand what is happening.
> >
> > Paulo
>
> Hi,
> I had a similar problem some time ago. For some reason creating the timer
> on the stack worked, while creating it on the heap did not (i.e. with new).
> I didn't look further into it.
OK, I investigated a little further and understood what the problem is:
QEventDispatcherGlib::registerTimer
QObject::startTimer_GLIB: timers cannot be started from another thread
Register Timer for object: QDBusConnectionPrivate(0x80db958)
Object thread: QThread(0x806c158)
this->thread: QThread(0x806c158)
QThread::currentThread: MyThread(0x8127870)
The problem isn't with my timers but with QDBus timers.
I guess this will happen everytime threads are used.
This can cause any problems or should be ignored?
Paulo
More information about the kde-core-devel
mailing list