Event loop questions Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Event loop questions

Post by zobbo »

Hi,

I have a problem when trying to exit an event loop I've created. I check if there is a pending event before exiting the loop, otherwise I may miss events that I'm waiting for.

However there seems to be a mystery event stuck in the event queue which is preventing the loop exiting. I can force it out with loop->Dispatch(), but that doesn't really explain what is causing it.

My questions are, how can I check what the event stuck in the queue is? I am using FilterEvent but it doesn't seem to show the other event, or at least it looks the same when I don't force the event with Dispatch().

And do idle events count as pending events in the event queue?


Thanks,
Zobbo.
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium
Azagaros
Experienced Solver
Experienced Solver
Posts: 59
Joined: Sat Feb 20, 2010 6:26 pm

Post by Azagaros »

My thought you are trying to read a message twice, for example you have a message handler active and your filter routine. You may need a message skip in the other or routing situation. The possibility also is a library message handler that isn't cleaning up properly.
17+ years of c++, currently open watcom and wxWidgets, MFC experience. C::B user.
The world begins again. Are you going to be one of the 2 billion left?
zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Post by zobbo »

Azagaros wrote:My thought you are trying to read a message twice, for example you have a message handler active and your filter routine. You may need a message skip in the other or routing situation. The possibility also is a library message handler that isn't cleaning up properly.
Thanks Azagoras. Yes, maybe something like that. My filter routine always returns -1 so it shouldn't affect the events. It seems to be timing related also, if I put certain breakpoints in it will get stuck in the loop, otherwise it works because I exit it if there is nothing pending. Still makes debugging problematic though if it gets stuck in the loop sometimes. I did used to use skip but removed it, so maybe I should look into that again. I wonder if also I should run it off a worker thread so I'm not relying on the loop to exit.
Cheers,

Zobbo
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium
Post Reply