From 34b3fcdcb8271e711ff4cbf57caa7f2b1bbefe98 Mon Sep 17 00:00:00 2001
From: adrien-matta <a.matta@surrey.ac.uk>
Date: Tue, 21 Jul 2015 09:45:07 +0100
Subject: [PATCH] * Attempt to fix minor bug in linux

---
 NPLib/Core/NPAnalysisFactory.cxx | 3 ---
 NPLib/Core/NPDetectorFactory.cxx | 3 ---
 NPLib/Core/NPDetectorManager.cxx | 4 +++-
 NPLib/Core/NPOptionManager.cxx   | 7 +++----
 NPLib/Core/NPVSpectra.cxx        | 6 ++----
 NPLib/Utility/npanalysis.cxx     | 4 ++--
 6 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/NPLib/Core/NPAnalysisFactory.cxx b/NPLib/Core/NPAnalysisFactory.cxx
index 4532266f4..b98af2d93 100644
--- a/NPLib/Core/NPAnalysisFactory.cxx
+++ b/NPLib/Core/NPAnalysisFactory.cxx
@@ -11,9 +11,6 @@ AnalysisFactory::AnalysisFactory(){
 
 /////////////////////////////////////////////////////////////////////////////////
 AnalysisFactory::~AnalysisFactory(){
-  if(m_Instance!=0)
-    delete m_Instance;
-
   m_Instance = 0 ;
 }
 
diff --git a/NPLib/Core/NPDetectorFactory.cxx b/NPLib/Core/NPDetectorFactory.cxx
index 116b72a07..42cca6377 100644
--- a/NPLib/Core/NPDetectorFactory.cxx
+++ b/NPLib/Core/NPDetectorFactory.cxx
@@ -27,9 +27,6 @@ DetectorFactory::DetectorFactory(){
 
 /////////////////////////////////////////////////////////////////////////////////
 DetectorFactory::~DetectorFactory(){
-  if(m_Instance!=0)
-    delete m_Instance;
-
   m_Instance = 0 ;
 }
 
diff --git a/NPLib/Core/NPDetectorManager.cxx b/NPLib/Core/NPDetectorManager.cxx
index df9171164..28c4c9b77 100644
--- a/NPLib/Core/NPDetectorManager.cxx
+++ b/NPLib/Core/NPDetectorManager.cxx
@@ -189,7 +189,9 @@ void NPL::DetectorManager::ReadConfigurationFile(string Path)   {
           ReadingStatusTarget = false;
 
       }
-    }///////////////////////////////////////////
+    }
+    
+    ///////////////////////////////////////////
     /////////// Search for Detectors ///////////
     ////////////////////////////////////////////
     else{
diff --git a/NPLib/Core/NPOptionManager.cxx b/NPLib/Core/NPOptionManager.cxx
index cfdd9b14c..6e76cf380 100644
--- a/NPLib/Core/NPOptionManager.cxx
+++ b/NPLib/Core/NPOptionManager.cxx
@@ -151,8 +151,7 @@ NPOptionManager::NPOptionManager(int argc, char** argv){
   ReadTheInputArgument(argc,argv);
 }
 ////////////////////////////////////////////////////////////////////////////////
-NPOptionManager::NPOptionManager(string arg)
-{  
+NPOptionManager::NPOptionManager(string arg){  
   vector<char *> args;
   istringstream iss(arg);
 
@@ -167,9 +166,9 @@ NPOptionManager::NPOptionManager(string arg)
 
   ReadTheInputArgument(args.size()-1, &args[0]);
 
-  for(size_t i = 0; i < args.size(); i++)
+/*  for(size_t i = 0; i < args.size(); i++)
     delete[] args[i];
-
+*/
 }
 ////////////////////////////////////////////////////////////////////////////////
 void NPOptionManager::CheckArguments(){
diff --git a/NPLib/Core/NPVSpectra.cxx b/NPLib/Core/NPVSpectra.cxx
index 7819243a1..2a255b77f 100644
--- a/NPLib/Core/NPVSpectra.cxx
+++ b/NPLib/Core/NPVSpectra.cxx
@@ -134,10 +134,8 @@ void VSpectra::WriteSpectra(string filename){
    // Go back to root directory
    f->cd();
 
-   // close file and delete associate pointer only in case
-   // of filename.
-       if (filename != "VOID") {
+   // close file
+   if (filename != "VOID") {
       f->Close();
-      delete f;
    }
 }
diff --git a/NPLib/Utility/npanalysis.cxx b/NPLib/Utility/npanalysis.cxx
index f2954ec18..f428b17ac 100644
--- a/NPLib/Utility/npanalysis.cxx
+++ b/NPLib/Utility/npanalysis.cxx
@@ -41,13 +41,13 @@ int main(int argc , char** argv){
   if (myOptionManager->IsDefault("DetectorConfiguration")) {
     string name = RootInput::getInstance(inputfilename)->DumpAsciiFile("DetectorConfiguration");
     myOptionManager->SetDetectorFile(name);
-    cout << "\033[1;33mWarning: No Detector file given, using Input tree one\033[0m"<<endl;;
+    cout << "\033[1;33mWarning: No Detector file given, using Input tree one (if any)\033[0m"<<endl;;
   }
 
   if (myOptionManager->IsDefault("EventGenerator")) {
     string name = RootInput::getInstance(inputfilename)->DumpAsciiFile("EventGenerator");
     myOptionManager->SetReactionFile(name);
-    cout << "\033[1;33mWarning: No Event file given, using Input tree one\033[0m"<<endl;;
+    cout << "\033[1;33mWarning: No Event file given, using Input tree one (if any)\033[0m"<<endl;;
   }
 
   // get input files from NPOptionManager
-- 
GitLab