From 9243d674ef9c237878bd732304c05de67210ecae Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Mon, 19 Jan 2015 13:36:49 +0100 Subject: [PATCH] Fix Jira issue #ROOT-6985: cannot open TBrowser() from ROOT prompt Fix a crash in TRootBrowser when having the option Canvas.ShowEditor: true in the .rootrc file. --- gui/gui/src/TRootBrowser.cxx | 2 +- gui/gui/src/TRootCanvas.cxx | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gui/gui/src/TRootBrowser.cxx b/gui/gui/src/TRootBrowser.cxx index 9723d17..6371f86 100644 --- a/gui/gui/src/TRootBrowser.cxx +++ b/gui/gui/src/TRootBrowser.cxx @@ -1136,7 +1136,7 @@ void TRootBrowser::StopEmbedding(const char *name, TGLayoutHints *layout) if (name && strlen(name)) { SetTabTitle(name, fEditPos, fEditSubPos); } - fEditTab->Selected(fEditSubPos); + if (fEditTab) fEditTab->Selected(fEditSubPos); fEditFrame = fEditTab = 0; fEditPos = fEditSubPos = -1; } diff --git a/gui/gui/src/TRootCanvas.cxx b/gui/gui/src/TRootCanvas.cxx index 96a8fc1..06515a9 100644 --- a/gui/gui/src/TRootCanvas.cxx +++ b/gui/gui/src/TRootCanvas.cxx @@ -1481,19 +1481,23 @@ void TRootCanvas::ShowEditor(Bool_t show) fEmbedded = kTRUE; if (show && (!fEditor || !((TGedEditor *)fEditor)->IsMapped())) { if (!browser->GetTabLeft()->GetTabTab("Pad Editor")) { - browser->StartEmbedding(TRootBrowser::kLeft); - if (!fEditor) - fEditor = TVirtualPadEditor::GetPadEditor(kTRUE); - else { - ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot()); - ((TGedEditor *)fEditor)->MapWindow(); - } - browser->StopEmbedding("Pad Editor"); - fEditor->SetGlobal(kFALSE); - gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor); - if (fEditor) { - ((TGedEditor *)fEditor)->SetCanvas(fCanvas); - ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down); + if (browser->GetActFrame()) { //already in edit mode + TTimer::SingleShot(200, "TRootCanvas", this, "ShowEditor(=kTRUE)"); + } else { + browser->StartEmbedding(TRootBrowser::kLeft); + if (!fEditor) + fEditor = TVirtualPadEditor::GetPadEditor(kTRUE); + else { + ((TGedEditor *)fEditor)->ReparentWindow(fClient->GetRoot()); + ((TGedEditor *)fEditor)->MapWindow(); + } + browser->StopEmbedding("Pad Editor"); + fEditor->SetGlobal(kFALSE); + gROOT->GetListOfCleanups()->Remove((TGedEditor *)fEditor); + if (fEditor) { + ((TGedEditor *)fEditor)->SetCanvas(fCanvas); + ((TGedEditor *)fEditor)->SetModel(fCanvas, fCanvas, kButton1Down); + } } } else -- 1.8.2