Something wrong with QWaitCondition
For a long time i compiled my program only on Linux with qt 4.6.2. But then decided to watch it on my windows xp using qt creator with qt 4.7.0. What happened: on linux every signal was sent to gui thread and waked second thread, but in windows it (sending signal) worked only for 1-4 times and then second thread went to wait condition forever.
I have main gui thread and second thread, that calls wait() function for lots of times.
in my second thread:
- ther is class Finder
- QWaitCondition wCond;
- QMutex sync;
- QImage img;
- signals:
- void needScreenshot();
- void Finder::wait()
- {
- sync.lock();
- emit needScreenshot();
- wCond.wait(&sync);
- sync.unlock();
- }
- {
- img = screenshot;
- wCond.wakeOne();
- }
- in main gui thread
- Finder* finder;
- void makeScreeshot()
- {
- unsigned long windowId;
- windowId=sc.getHeroesWinId(mainWinForm_.lineEdit->text());//returns window id depends on system, i can list it's code if needed
- if(windowId == 0)
- {
- QImage img;
- finder->imageRecieved(img);
- return;
- }
- finder->imageRecieved(img);
- }
1 reply
You must log in to post a reply. Not a member yet? Register here!


