[vtk-developers] Patch for vtkCocoaRenderWindowInteractor TerminateApp behavior

Pat Marion pat.marion at kitware.com
Fri Aug 3 19:11:55 EDT 2012


> Is that a valid use case?

Not sure :)  I wouldn't personally design an application around this use
case (I prefer Qt's event loop), but I can see why it's useful to folks who
want to design a single-threaded game-engine style loop:

while (1)
{

// handle pending key & mouse events

// render if dirty

// do stuff

}

 The problem is that the vtkRenderWindowInteractor does not provide any API
for dispatching pending events and then returning control.  It would be
great if there was API like:

void DispatchPendingEvents();
void WaitForEvents(timeout);

But, since that API is missing, you can roughly accomplish the same thing
by calling Start() after posting a timer event to call TerminateApp after
some number of milliseconds.  I think that TerminateApp is probably a poor
name, since it certainly does not terminate the app, it just breaks the
event loop and returns so that you can clean up your app safely.  The
inconsistent behavior is that, on OSX, TerminateApp doesn't just break the
event loop, it also calls close on your render window for no good apparent
reason.

Anyway, I appreciate you taking the time to look over the patch details!
If we decide to proceed with the patch, you said some more changes might be
needed, any hints what those might be?

Pat



On Fri, Aug 3, 2012 at 5:38 PM, Sean McBride <sean at rogue-research.com>wrote:

> On Fri, 3 Aug 2012 11:36:00 -0400, Pat Marion said:
>
> >Attached is a test program that makes repeated calls to interactor Start()
> >and TerminateApp().
>
> Is that a valid use case?
>
> From its name, I thought TerminateApp() was supposed to terminate the
> process?  If so, it doesn't make sense to do anything after. :)
>
> The doxygen does not help me, saying only "This function is called on
> 'q','e' keypress if exitmethod is not specified and should be overridden by
> platform dependent subclasses to provide a termination procedure if one is
> required."
>
> Are you saying that TerminateApp() is it meant to be the complement of
> Start()?  (That seems to be the case with vtkCarbonRenderWindowInteractor)
>
> If so, I think your patch is a start, but more changes are needed....
>
> Cheers,
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 sean at rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20120803/593c85ec/attachment.html>


More information about the vtk-developers mailing list