improved the close canvas mechanism (from the global to the object level)

This commit is contained in:
2017-11-30 22:02:25 +01:00
parent be1e47e480
commit 1f73e808b5
3 changed files with 18 additions and 3 deletions

View File

@@ -1502,12 +1502,25 @@ void PMusrCanvas::HandleMenuPopup(Int_t id)
*/
void PMusrCanvas::LastCanvasClosed()
{
// cout << endl << ">> in last canvas closed check ...";
// cerr << ">> in last canvas closed check. gROOT->GetListOfCanvases()->GetEntries()=" << gROOT->GetListOfCanvases()->GetEntries() << endl;
if (gROOT->GetListOfCanvases()->IsEmpty()) {
Done(0);
}
}
//--------------------------------------------------------------------------
// WindowClosed (SLOT)
//--------------------------------------------------------------------------
/**
* <p>Slot called when the canvas is closed. Seems to be necessary on some systems.
*/
void PMusrCanvas::WindowClosed()
{
// cerr << ">> fMainCanvas->GetName()=" << fMainCanvas->GetName() << endl;
gROOT->GetListOfCanvases()->Remove(fMainCanvas);
LastCanvasClosed();
}
//--------------------------------------------------------------------------
// SaveGraphicsAndQuit
//--------------------------------------------------------------------------
@@ -2374,9 +2387,12 @@ void PMusrCanvas::InitMusrCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy,
return;
}
fMainCanvas->Connect("Closed()", "PMusrCanvas", this, "LastCanvasClosed()");
// add canvas menu if not in batch mode
if (!fBatchMode) {
fImp = (TRootCanvas*)fMainCanvas->GetCanvasImp();
fImp->Connect("CloseWindow()", "PMusrCanvas", this, "WindowClosed()");
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&Musrfit");