Commit e11a77cb authored by Yannick Verdie's avatar Yannick Verdie

use sleep instead of usleep on window

parent f2971aeb
...@@ -230,6 +230,8 @@ CV_IMPL int cvWaitKey( int arg ) ...@@ -230,6 +230,8 @@ CV_IMPL int cvWaitKey( int arg )
if (arg>0) if (arg>0)
timer.start(arg); timer.start(arg);
//QMutex dummy;
while(!guiMainThread._bTimeOut) while(!guiMainThread._bTimeOut)
{ {
qApp->processEvents(QEventLoop::AllEvents); qApp->processEvents(QEventLoop::AllEvents);
...@@ -245,9 +247,25 @@ CV_IMPL int cvWaitKey( int arg ) ...@@ -245,9 +247,25 @@ CV_IMPL int cvWaitKey( int arg )
mutexKey.unlock(); mutexKey.unlock();
if (result!=-1) if (result!=-1)
{
break; break;
}
else else
{
/*
* //will not work, I broke the event loop !!!!
dummy.lock();
QWaitCondition waitCondition;
waitCondition.wait(&dummy, 2);
*/
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
sleep(2);
#else
usleep(2);//to decrease CPU usage usleep(2);//to decrease CPU usage
#endif
}
} }
guiMainThread._bTimeOut = false; guiMainThread._bTimeOut = false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment