Featured post
c++ - QThread confusion -
i'm using qt 4.7.0 (32 bit) on windows 7 ultimate (32 bit) machine. i've been using qt version 4.0 or 4.2 , i've used 4.x.y releases.
recently, qt 4.7 i've faced trouble.
i've written multithreaded application in older version of qt. i've forgotten version last version compiled , ran 4.5.x or 4.6.x. threaded part doesn't seem working correctly in 4.7, or misunderstood something. here problem:
the main thread starts thinker thread. following run() function of thinker thread:
void thinkerthread::run() { _threads_running = nsubthinkers; // ... _sub_thinker[0].start(); // ... _sub_thinker[1].start(); exec(); } the _sub_thinker's finished() signal connected thinkerthread::subthinkerfinished() slot _sub_thinkers. when _sub_thinkers finish, thinkerthread::subthinkerfinished() calls quit().
there place quit() called:
void thinkerthread::trykill() { (int = 0; < nsubthinkers; i++) _sub_thinker[i].trykill(); quit(); } from main thread, execution follows:
- thinker.trykill() [note: on fist run, thinker wasn't running.]
- thinker.start()
thinker's finished() signal connected automove().
for previous versions of qt, automove() called after thinker::quit() called thinkerthread::subthinkerfinished(). in 4.7 i'm seeing automove() called after first call of thinker.trykill(), though thread wasn't running.
any idea?
of course can check inside thinkerthread::trykill() if thinker running or not. i'd know why happening.
thanks.
i've found qthread::finished() emitted every time qthread::quit() called irrespective of state of qthread (i.e., running/not running). didn't case previous versions of qt.
- Get link
- X
- Other Apps
Comments
Post a Comment