Re: embedding ROOT (question 1)

Pasha Murat (murat@cdfsga.fnal.gov)
Fri, 26 Sep 1997 23:22:45 -0500


Experimenting with running ROOT in embedded mode I ended up with the
following example
--------------------------------------------------------------------------------
#include "TROOT.h"
#include "TRint.h"
extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
int Error; // needed by Motif

TROOT root("Rint","The ROOT Interactive Interface", initfuncs);

main(int argc, char **argv) {

TRint* theApp = new TRint("example 1", &argc, argv, NULL, 0);
theApp->Run(kTRUE);

delete theApp;

theApp = new TRint("example 2", &argc, argv, NULL, 0);
theApp->Run(kTRUE);
delete theApp;
}
--------------------------------------------------------------------------------

which prototypes 2 subsequent calls to ROOT event loop. This example generates
diagnostics:

root [0] .q
root [1] Error in <TApplication::TApplication>: only one instance of TApplication allowed

The diagnostics is due to the fact that TRint::TRint(..) ctor does some nontrivial
actions including dynamic memory allocations and registering allocated pointers in
gSystem. The destructor for TRint class does however nothing:
--------------------------------------------------------- RINT_Rint.cxx
TRint::~TRint()
{

}
--------------------------------------------------------------------------------

so the second call to constructor interferes with the first one.
Is it a design feature or a place which should be fixed?

Thanks, Pasha