From 1a79be08dd9d74ee45afbde7fa7b364b5a1786fb Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Fri, 8 Apr 2011 15:50:33 +0000
Subject: [PATCH] save the interpreter context just before calling the script,
 to avoid it to wipe all symbols away with a possible gROOT->Reset().

git-svn-id: http://root.cern.ch/svn/root/trunk@38782 27541ba8-7e3a-0410-8455-c3a389f83636
---
 etc/html/saveScriptOutput.C | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/etc/html/saveScriptOutput.C b/etc/html/saveScriptOutput.C
index 8eac791360f..8695b5f42fd 100644
--- a/etc/html/saveScriptOutput.C
+++ b/etc/html/saveScriptOutput.C
@@ -12,7 +12,8 @@
 #include "TEnv.h"
 #include "TVirtualX.h"
 
-int saveScriptOutput(const char* script, const char* outdir, Bool_t compiled) {
+int saveScriptOutput(const char* script, const char* outdir, Bool_t compiled)
+{
    // Run script and save all windows to
    // outdir/script_0.png, outdir/script_1.png, ...
 
@@ -34,6 +35,12 @@ int saveScriptOutput(const char* script, const char* outdir, Bool_t compiled) {
       cmd += "+";
    if (!gROOT->IsBatch())
       gVirtualX->Sync(1);
+
+   // save current interpreter context to avoid gROOT->Reset()
+   // in the script to cause havoc by wiping everything away
+   gInterpreter->SaveContext();
+   gInterpreter->SaveGlobalsContext();
+
    gROOT->ProcessLine(cmd, &err);
    if (err != TInterpreter::kNoError)
       return kCannotRunScript;
-- 
GitLab