I have a MainWin derived from TCanvas with a function that can be called from
the "Right Mouse Menu". See program and header file below. But as soon as I
call the DoNothing() - function from the mouse menu the destructor of my canvas
class (MainWin) is called. You can control that by the outputs as well as in a
debugger session.
The LinkDef.h file:
=================================================
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class MainWin;
#endif
=================================================
The header file:
=================================================
#include <TCanvas.h>
class MainWin : public TCanvas
{
public:
MainWin(Text_t* name, Text_t* title, Int_t wtopx, Int_t wtopy, Int_t ww,
Int_t wh)
: TCanvas(name, title, wtopx, wtopy, ww, wh) {}
MainWin() : TCanvas() {}
~MainWin();
void DoNothing(); // *MENU*
ClassDef(MainWin, 1)
};
==================================================================
and here the program:
==================================================================
#include <TROOT.h>
#include <TApplication.h>
#include "+Y"
extern void InitGui();
VoidFuncPtr_t initFuncs[] = {InitGui, 0};
TROOT root ("ISDC", "Display", initFuncs);
main(int argc, char ** argv)
{
TApplication theApp("ISDC_OSM", &argc, argv);
MainWin mainWin("Display", "Display", 10, 60, 900, 600);
theApp.Run();
}
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
ClassImp(MainWin)
/////////////////////////////////////////////////////////////////////////
MainWin::~MainWin()
{
printf("Now we are in Destructor of MainWin\n");
}
/////////////////////////////////////////////////////////////////////////
void MainWin::DoNothing()
{
printf("Now we are in DoNothing\n");
}
================================================================