added some more sanity checks for musrview.
This commit is contained in:
@@ -135,6 +135,7 @@ int main(int argc, char *argv[])
|
|||||||
std::stringstream errMsg;
|
std::stringstream errMsg;
|
||||||
|
|
||||||
memset(fileName, '\0', sizeof(fileName));
|
memset(fileName, '\0', sizeof(fileName));
|
||||||
|
memset(graphicsExtension, '\0', sizeof(graphicsExtension));
|
||||||
|
|
||||||
// add default shared library path /usr/local/lib if not already persent
|
// add default shared library path /usr/local/lib if not already persent
|
||||||
const char *dsp = gSystem->GetDynamicPath();
|
const char *dsp = gSystem->GetDynamicPath();
|
||||||
@@ -149,7 +150,7 @@ int main(int argc, char *argv[])
|
|||||||
for (int i=1; i<argc; i++) {
|
for (int i=1; i<argc; i++) {
|
||||||
if (strstr(argv[i], ".msr") || strstr(argv[i], ".mlog")) {
|
if (strstr(argv[i], ".msr") || strstr(argv[i], ".mlog")) {
|
||||||
if (strlen(fileName) == 0) {
|
if (strlen(fileName) == 0) {
|
||||||
strcpy(fileName, argv[i]);
|
strncpy(fileName, argv[i], sizeof(fileName));
|
||||||
} else {
|
} else {
|
||||||
std::cerr << std::endl << "**ERROR** only one file name allowed." << std::endl;
|
std::cerr << std::endl << "**ERROR** only one file name allowed." << std::endl;
|
||||||
show_syntax = true;
|
show_syntax = true;
|
||||||
@@ -188,7 +189,7 @@ int main(int argc, char *argv[])
|
|||||||
!strcmp(argv[i], "--xpm") || !strcmp(argv[i], "--root")) {
|
!strcmp(argv[i], "--xpm") || !strcmp(argv[i], "--root")) {
|
||||||
|
|
||||||
graphicsOutput = true;
|
graphicsOutput = true;
|
||||||
strcpy(graphicsExtension, argv[i]+2);
|
strncpy(graphicsExtension, argv[i]+2, sizeof(graphicsExtension));
|
||||||
} else if (!strcmp(argv[i], "--ascii")) {
|
} else if (!strcmp(argv[i], "--ascii")) {
|
||||||
asciiOutput = true;
|
asciiOutput = true;
|
||||||
} else if (!strcmp(argv[i], "--timeout")) {
|
} else if (!strcmp(argv[i], "--timeout")) {
|
||||||
@@ -220,13 +221,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// read startup file
|
// read startup file
|
||||||
char startup_path_name[128];
|
char startup_path_name[128];
|
||||||
|
memset(startup_path_name, '\0', sizeof(startup_path_name));
|
||||||
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
|
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
|
||||||
std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
|
std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
|
||||||
if (!startupHandler->StartupFileFound()) {
|
if (!startupHandler->StartupFileFound()) {
|
||||||
std::cerr << std::endl << ">> musrview **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
|
std::cerr << std::endl << ">> musrview **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
} else {
|
} else {
|
||||||
strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
|
strncpy(startup_path_name, startupHandler->GetStartupFilePath().Data(), sizeof(startup_path_name));
|
||||||
saxParser->ConnectToHandler("PStartupHandler", startupHandler.get());
|
saxParser->ConnectToHandler("PStartupHandler", startupHandler.get());
|
||||||
//status = saxParser->ParseFile(startup_path_name);
|
//status = saxParser->ParseFile(startup_path_name);
|
||||||
// parsing the file as above seems to lead to problems in certain environments;
|
// parsing the file as above seems to lead to problems in certain environments;
|
||||||
@@ -345,7 +347,7 @@ int main(int argc, char *argv[])
|
|||||||
TApplication app("App", &cc, args.data());
|
TApplication app("App", &cc, args.data());
|
||||||
|
|
||||||
std::vector<PMusrCanvas*> canvasVector;
|
std::vector<PMusrCanvas*> canvasVector;
|
||||||
PMusrCanvas *musrCanvas;
|
PMusrCanvas *musrCanvas = nullptr;
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
|
for (unsigned int i=0; i<msrHandler->GetMsrPlotList()->size(); i++) {
|
||||||
@@ -364,12 +366,21 @@ int main(int argc, char *argv[])
|
|||||||
graphicsOutput||asciiOutput,
|
graphicsOutput||asciiOutput,
|
||||||
fourier, avg, theoAtData);
|
fourier, avg, theoAtData);
|
||||||
|
|
||||||
|
if (musrCanvas == nullptr) {
|
||||||
|
errMsg << ">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
|
||||||
|
std::cerr << errMsg.str();
|
||||||
|
if (show_errMsgBox)
|
||||||
|
musrview_error_msg(errMsg.str());
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!musrCanvas->IsValid()) {
|
if (!musrCanvas->IsValid()) {
|
||||||
errMsg << ">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
|
errMsg << ">> musrview **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.\n";
|
||||||
std::cerr << errMsg.str();
|
std::cerr << errMsg.str();
|
||||||
if (show_errMsgBox)
|
if (show_errMsgBox)
|
||||||
musrview_error_msg(errMsg.str());
|
musrview_error_msg(errMsg.str());
|
||||||
ok = false;
|
ok = false;
|
||||||
|
delete musrCanvas;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user