Re: [ROOT] How to survive the "gApplication->Terminate(0);"

From: Brett Viren (bv@bnl.gov)
Date: Tue Dec 10 2002 - 17:02:35 MET


Jacek M. Holeczek writes:
 > Hi,
 > Assume you have an application which internally does :
 > 	new TRint("MyApplication", 0, 0, 0, 0);
 > 	...
 > 	gApplication->Run(kTRUE);
 > and when the main gui window is deleted it does :
 > 	gApplication->Terminate(0);
 > 
 > My question is ... how can I convince ROOT to survive this ?
 > The point is that ... the application created Rint, but I want to take
 > control over it afterwards.
 > 
 > What I would like to do is :
 > 	gApplication->CompletalyIgnoreTerminate();
 > 	delete MainGuiWindow; // it will call gApplication->Terminate(0)
 > 	gApplication->DontIgnoreTerminate();
 > 
 > Well, I could do this now using :
 > 	Bool_t OldReturn = gApplication->ReturnFromRun();
 > 	Bool_t OldDone = gSystem->GetDone();
 > 	gApplication->SetReturnFromRun(kTRUE);
 > 	delete MainGuiWindow;
 > 	gSystem->SetDone(OldDone);
 > 	gApplication->SetReturnFromRun(OldReturn);
 > unfortunately ... TSystem class does not provide "GetDone" nor "SetDone".

Are recursive TApplication creation allowed?  If so, try creating your
own before the "sub app' does.  Save it in a private pointer.  Don't
use gApplication to reference it since you never know what it points
to.

BTW, GTK's GLIB lets one do just this:

http://developer.gnome.org/doc/API/glib/glib-the-main-event-loop.html

It is how you implement dialog windows that don't freeze the rest of
the application.  If recursive TApplication creation doen't yet exist,
maybe looking at how GLIB does it could be of use.

-Brett.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET