diff --git a/src/classes/PStartupHandler.cpp b/src/classes/PStartupHandler.cpp index c0f0b06b..a70edfb1 100644 --- a/src/classes/PStartupHandler.cpp +++ b/src/classes/PStartupHandler.cpp @@ -74,9 +74,9 @@ PStartupHandler::PStartupHandler() strncpy(musrpath, pmusrpath, sizeof(musrpath)); } sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath); + fStartupFilePath = TString(startup_path_name); if (StartupFileExists(startup_path_name)) { fStartupFileFound = true; - fStartupFilePath = TString(startup_path_name); } } } diff --git a/src/musrfit.cpp b/src/musrfit.cpp index e479b82c..31f705dc 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -406,13 +406,9 @@ int main(int argc, char *argv[]) char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); - strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); - saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing musrfit_startup.xml."; - cout << endl; + if (!startupHandler->StartupFileFound()) { + cerr << endl << "**WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data(); + cerr << endl; // clean up if (saxParser) { delete saxParser; @@ -422,6 +418,24 @@ int main(int argc, char *argv[]) delete startupHandler; startupHandler = 0; } + } else { + strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); + saxParser->ConnectToHandler("PStartupHandler", startupHandler); + status = saxParser->ParseFile(startup_path_name); + // check for parse errors + if (status) { // error + cerr << endl << "**WARNING** reading/parsing musrfit_startup.xml."; + cerr << endl; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } + } } // read msr-file diff --git a/src/musrt0.cpp b/src/musrt0.cpp index 259d66b4..d202b51b 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -172,14 +172,9 @@ int main(int argc, char *argv[]) char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); - strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); - saxParser->ConnectToHandler("PStartupHandler", startupHandler); - status = saxParser->ParseFile(startup_path_name); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing musrfit_startup.xml failed."; - cout << endl; -/* + if (!startupHandler->StartupFileFound()) { + cerr << endl << "**WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data(); + cerr << endl; // clean up if (saxParser) { delete saxParser; @@ -189,9 +184,25 @@ int main(int argc, char *argv[]) delete startupHandler; startupHandler = 0; } -*/ + } else { + strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); + saxParser->ConnectToHandler("PStartupHandler", startupHandler); + status = saxParser->ParseFile(startup_path_name); + // check for parse errors + if (status) { // error + cerr << endl << "**WARNING** reading/parsing musrfit_startup.xml."; + cerr << endl; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } + } } - startupHandler->CheckLists(); // read msr-file PMsrHandler *msrHandler = new PMsrHandler(filename); diff --git a/src/musrview.cpp b/src/musrview.cpp index 9358a93b..48b8f64c 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -145,24 +145,38 @@ int main(int argc, char *argv[]) char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); PStartupHandler *startupHandler = new PStartupHandler(); - saxParser->ConnectToHandler("PStartupHandler", startupHandler); - strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); - status = saxParser->ParseFile(startup_path_name); - // check for parse errors - if (status) { // error - cout << endl << "**WARNING** reading/parsing musrfit_startup.xml failed."; - cout << endl; + if (!startupHandler->StartupFileFound()) { + cerr << endl << "**WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data(); + cerr << endl; // clean up - if (startupHandler) { - delete startupHandler; - startupHandler = 0; - } if (saxParser) { delete saxParser; saxParser = 0; } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } + } else { + strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data()); + saxParser->ConnectToHandler("PStartupHandler", startupHandler); + status = saxParser->ParseFile(startup_path_name); + // check for parse errors + if (status) { // error + cerr << endl << "**WARNING** reading/parsing musrfit_startup.xml."; + cerr << endl; + // clean up + if (saxParser) { + delete saxParser; + saxParser = 0; + } + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } + } + startupHandler->CheckLists(); } - startupHandler->CheckLists(); // read msr-file PMsrHandler *msrHandler = new PMsrHandler(fileName);