should prevent crash if musrfit_startup.xml is NOT found anywhere.
This commit is contained in:
parent
4cdc4dbf1d
commit
5c69c21f56
@ -97,7 +97,6 @@ PStartupHandler::PStartupHandler()
|
|||||||
Char_t *home=0;
|
Char_t *home=0;
|
||||||
Char_t musrpath[128];
|
Char_t musrpath[128];
|
||||||
Char_t startup_path_name[128];
|
Char_t startup_path_name[128];
|
||||||
Bool_t found = false;
|
|
||||||
|
|
||||||
strncpy(musrpath, "", sizeof(musrpath));
|
strncpy(musrpath, "", sizeof(musrpath));
|
||||||
|
|
||||||
@ -106,35 +105,42 @@ PStartupHandler::PStartupHandler()
|
|||||||
if (StartupFileExists(startup_path_name)) {
|
if (StartupFileExists(startup_path_name)) {
|
||||||
fStartupFileFound = true;
|
fStartupFileFound = true;
|
||||||
fStartupFilePath = TString(startup_path_name);
|
fStartupFilePath = TString(startup_path_name);
|
||||||
} else { // startup file is not found in the current directory
|
}
|
||||||
|
if (!fStartupFileFound) { // startup file not found in the current directory
|
||||||
// check if the startup file is found under $HOME/.musrfit
|
// check if the startup file is found under $HOME/.musrfit
|
||||||
home = getenv("HOME");
|
home = getenv("HOME");
|
||||||
if (home != 0) {
|
if (home != 0) {
|
||||||
sprintf(musrpath, "%s/.musrfit", home);
|
sprintf(startup_path_name, "%s/.musrfit/musrfit_startup.xml", home);
|
||||||
found = true;
|
if (StartupFileExists(startup_path_name)) {
|
||||||
|
fStartupFilePath = TString(startup_path_name);
|
||||||
|
fStartupFileFound = true;
|
||||||
}
|
}
|
||||||
pmusrpath = getenv("MUSRFITPATH");
|
}
|
||||||
if (!found) {
|
}
|
||||||
|
if (!fStartupFileFound) { // startup file not found in $HOME/.musrfit
|
||||||
// check if the MUSRFITPATH system variable is set
|
// check if the MUSRFITPATH system variable is set
|
||||||
|
pmusrpath = getenv("MUSRFITPATH");
|
||||||
if (pmusrpath != 0) {
|
if (pmusrpath != 0) {
|
||||||
if (strcmp(pmusrpath, "")) { // MUSRFITPATH variable set but empty
|
sprintf(startup_path_name, "%s/musrfit_startup.xml", pmusrpath);
|
||||||
found = true;
|
if (StartupFileExists(startup_path_name)) {
|
||||||
|
fStartupFilePath = TString(startup_path_name);
|
||||||
|
fStartupFileFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) { // MUSRFITPATH not set or empty, will try default one
|
if (!fStartupFileFound) { // MUSRFITPATH not set or empty, will try $ROOTSYS/bin
|
||||||
home = getenv("ROOTSYS");
|
home = getenv("ROOTSYS");
|
||||||
|
if (home != 0) {
|
||||||
sprintf(musrpath, "%s/bin", home);
|
sprintf(musrpath, "%s/bin", home);
|
||||||
cerr << endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << endl;
|
cerr << endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << endl;
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
|
sprintf(startup_path_name, "%s/musrfit_startup.xml", musrpath);
|
||||||
fStartupFilePath = TString(startup_path_name);
|
|
||||||
if (StartupFileExists(startup_path_name)) {
|
if (StartupFileExists(startup_path_name)) {
|
||||||
|
fStartupFilePath = TString(startup_path_name);
|
||||||
fStartupFileFound = true;
|
fStartupFileFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
|
@ -614,10 +614,15 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (startupHandler)
|
||||||
startupHandler->SetStartupOptions(startup_options);
|
startupHandler->SetStartupOptions(startup_options);
|
||||||
|
|
||||||
// read msr-file
|
// read msr-file
|
||||||
PMsrHandler *msrHandler = new PMsrHandler(filename, startupHandler->GetStartupOptions());
|
PMsrHandler *msrHandler = 0;
|
||||||
|
if (startupHandler)
|
||||||
|
msrHandler = new PMsrHandler(filename, startupHandler->GetStartupOptions());
|
||||||
|
else
|
||||||
|
msrHandler = new PMsrHandler(filename);
|
||||||
status = msrHandler->ReadMsrFile();
|
status = msrHandler->ReadMsrFile();
|
||||||
if (status != PMUSR_SUCCESS) {
|
if (status != PMUSR_SUCCESS) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user