On Mon, 22 Apr 2013 23:00:35 -0400 Rob Bresalier wrote:
RB> As I think this is a general issue with event loops, whether or not it is
RB> used by wxExecute(SYNC) or not, I think the proper place to solve this
RB> problem is in the event loop classes.
I agree that the changes should be done to wxEventLoop itself if they're
general and are not only needed in order to make wxExecute(SYNC) work.
However I'm not sure how would they be used, in general. I.e. what is our
API here? It seems we need some way to say "exit from this loop" instead of
just being able to terminate the currently running loop, which is all that
we currently have.
Moreover, we probably also need "exit from all the event loops up and
including this one" operation too. This would be mostly useful for the main
loop itself, i.e. currently wxApp::ExitMainLoop() doesn't do anything if
the main loop is not running. It would probably make more sense if it
exited from all the currently running loops and really terminated the
application in all situations. And it seems like your changes should allow
doing this easily -- but there is no API for this currently, is there?
So what do you think about defining this API for wxEventLoop precisely?
Would it be possible for you to do it, at least at the email level,
ensuring that this API is both
(a) Enough to make wxExecute(SYNC) implementation work.
and
(b) General enough to be useful in other situations.
?
Of course, if you can do it at the code level too (i.e. make a patch with
these changes and the associated documentation/tests updates), it would be
perfect, but if we can at least fix the API together, then I should be able
to extract the relevant parts of your patch myself, hopefully...
RB> BTW: The wx implementation in 2.9.4 (without my patch) of just 1 temporary
RB> event loop (not the modal dialog one) called from somewhere in the main
RB> loop is broken in the 2.9.4 release. It is because of the Cocoa API, you
RB> use [NSApp run] to start the loop, and [NSApp stop] to end the loop. But I
RB> have found out from testing that [NSApp stop] will not only cause the inner
RB> event loop to terminate, it will also cause the main loop to exit! Another
RB> undesired result of calling [NSApp stop] is that it can also cause a modal
RB> dialog event loop to also exit (which would be undesired). See my changes
RB> and extensive comments in
evtloop.mm for cocoa for how I solved this issue
RB> (reusing some tricks from webkit source code + adding my own).
Thanks, I'll try to have a look at this a bit later.
BTW, not saying that it necessarily needs to be done now, but this is just
an example of things that probably should have factored out of the main
patch: as the behaviour described above is clearly a bug, it would have
been great to have a commit fixing just it. Then another commit adding
nested/overlapped event loops support. And then the rest. Again, this is
not a criticism, just an explanation of how the changes could be organized
(and should be, if you make another patch in the future -- or, in fact, if
anybody else reading this, does) to make applying them much simpler.
RB> So if the trick has been shown to work on GTK, carbon and cocoa, then why
RB> do you think that it would not work everywhere? Where do you think it
RB> wouldn't work?
Well, we'd obviously need to make it work under MSW if this is to be an
officially supported part of the API. I think it shouldn't be a problem
there as MSW event loop API is pretty flexible (much more so than GTK or
Cocoa one), but I didn't look at the details of implementing it there yet.
Did you?
Thanks,
VZ