PDA

View Full Version : processEvents() and GUI responsivity



gianpatt
30th August 2008, 18:14
Hi all,
first of all: my english is not good, so sorry for this....

I have a strange problem with al little test that I am writing following:



#include <QApplication>
#include <QProgressDialog>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);

QProgressDialog dlg;
dlg.setRange(0, 0);
dlg.show();

// I want to simulate a process that takes a long time
for (int i = 0; i < 1000000; i++)
{
qDebug() << i;

// Call process event to have a GUI responsivity
QCoreApplication::processEvents();
}

dlg.hide();
return app.exec();
}


The program behaves as it should, but....if i click on ProgressDialog WindowBar (when lives close buttons :-) ) the loop counter freezes but the progress animation NOT! It 'a bit annoying.

I'm something wrong? I can do something to prevent this behavior?

I tried to intercept mouse events...
I tried this test on Mac.

jacek
30th August 2008, 19:27
It seems to work OK on Linux. Which Qt version do you use exactly?

codebehind
31st August 2008, 10:46
on my machine (linux running) it hides the dialog, but the counter is still running!

gianpatt maybe your counter freeze because it comes to the end? (it is a stupid question but,...)

gianpatt
31st August 2008, 13:53
It seems to work OK on Linux. Which Qt version do you use exactly?

4.3.4


gianpatt maybe your counter freeze because it comes to the end? (it is a stupid question but,...)

:) no...it freeze only when I click (and let down) on the window bar. If release the mouse count resume.

if block esecution with GDB i have this back trace...
it seems that main thread remains blocked while mouse is pressed down on window bar

#0 0x90009cd7 in mach_msg_trap ()
#1 0x90009c38 in mach_msg ()
#2 0x9082d227 in CFRunLoopRunSpecific ()
#3 0x9082ca42 in CFRunLoopRunInMode ()
#4 0x92df1878 in RunCurrentEventLoopInMode ()
#5 0x92df0f82 in ReceiveNextEventCommon ()
#6 0x92e39a74 in _AcquireNextEvent ()
#7 0x92eb4c70 in _TrackMouseLocationReturningEvent ()
#8 0x92f570a0 in TWindowTracker::TrackWindow ()
#9 0x930b0e66 in DragWindow ()
#10 0x92f597d0 in HIWindowFrameView::TrackSelf ()
#11 0x92e146a3 in HIView::EventHandler ()
#12 0x92df04d7 in DispatchEventToHandlers ()
#13 0x92defb7c in SendEventToEventTargetInternal ()
#14 0x92defa41 in SendEventToEventTargetWithOptions ()
#15 0x92eb3fb2 in SendControlDefTrack ()
#16 0x92eb3dca in HIView::ClickInternal ()
#17 0x92e8f025 in HIView::ClickSelf ()
#18 0x92e14612 in HIView::EventHandler ()
#19 0x92df04d7 in DispatchEventToHandlers ()
#20 0x92defb7c in SendEventToEventTargetInternal ()
#21 0x92df6f7c in SendEventToEventTarget ()
#22 0x92e8ed4f in HIView::Click ()
#23 0x92e8eb8b in HandleClickAsHIView ()
#24 0x92e8e531 in HandleWindowClick ()
#25 0x92e8dffe in HandleMouseEvent ()
#26 0x92e36468 in StandardWindowEventHandler ()
#27 0x92df04d7 in DispatchEventToHandlers ()
#28 0x92defb7c in SendEventToEventTargetInternal ()
#29 0x92df6f7c in SendEventToEventTarget ()
#30 0x92df7999 in ToolboxEventDispatcherHandler ()
#31 0x92df088e in DispatchEventToHandlers ()
#32 0x92defb7c in SendEventToEventTargetInternal ()
#33 0x92df6f7c in SendEventToEventTarget ()
#34 0x0105bbe2 in qt_mac_send_event ()
#35 0x0106906e in QEventDispatcherMac::processEvents ()
#36 0x002bab37 in QCoreApplication::processEvents ()
#37 0x00004435 in main ()


Every idea will be much appreciated.... :)

jacek
31st August 2008, 16:39
:) no...it freeze only when I click (and let down) on the window bar. If release the mouse count resume.
Ahh... I got it now. Such behavior was reported several times, but AFAIK it was on windows. You should better contact the Trolls (but try Qt 4.4.1 first).