From 9d12700f394c3d7f1afbd78ab0dcab43d238391b Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 25 Apr 2019 20:22:43 +0200 Subject: [PATCH 1/4] added some additional error tags. --- src/include/PMusr.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 70cebc09..44321518 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -41,15 +41,17 @@ //#endif #include "fftw3.h" -#define PMUSR_SUCCESS 0 -#define PMUSR_WRONG_STARTUP_SYNTAX -1 -#define PMUSR_MSR_FILE_NOT_FOUND -2 -#define PMUSR_MSR_ALLOCATION_ERROR -3 -#define PMUSR_MSR_SYNTAX_ERROR -4 -#define PMUSR_TOKENIZE_ERROR -5 -#define PMUSR_MSR_LOG_FILE_WRITE_ERROR -6 -#define PMUSR_MSR_FILE_WRITE_ERROR -7 -#define PMUSR_DATA_FILE_READ_ERROR -8 +#define PMUSR_SUCCESS 0 +#define PMUSR_SYNTAX_REQUEST -1 +#define PMUSR_WRONG_STARTUP_SYNTAX -2 +#define PMUSR_MSR_FILE_NOT_FOUND -3 +#define PMUSR_MSR_ALLOCATION_ERROR -4 +#define PMUSR_MSR_SYNTAX_ERROR -5 +#define PMUSR_TOKENIZE_ERROR -6 +#define PMUSR_MSR_LOG_FILE_WRITE_ERROR -7 +#define PMUSR_MSR_FILE_WRITE_ERROR -8 +#define PMUSR_DATA_FILE_READ_ERROR -9 +#define PMUSR_MSR_RUN_ERROR -10 #define PRUN_SINGLE_HISTO 0 #define PRUN_SINGLE_HISTO_RRF 1 From 96d9ba5f8813e0bbc3a8b5ef0b036f365adec88a Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 25 Apr 2019 20:23:40 +0200 Subject: [PATCH 2/4] added some more specifc error codes. --- src/musrview.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/musrview.cpp b/src/musrview.cpp index e21ddab9..597ee51e 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -98,6 +98,7 @@ void musrview_syntax() */ int main(int argc, char *argv[]) { + int result = PMUSR_SUCCESS; bool show_syntax = false; int status; bool success = true; @@ -119,7 +120,7 @@ int main(int argc, char *argv[]) // check input arguments if (argc == 1) { musrview_syntax(); - return PMUSR_SUCCESS; + return PMUSR_SYNTAX_REQUEST; } for (int i=1; iIsAllDataAvailable(); if (!success) { std::cerr << std::endl << ">> musrview **ERROR** Couldn't read all data files, will quit ..." << std::endl; + result = PMUSR_DATA_FILE_READ_ERROR; } // generate the necessary histogramms for the view PRunListCollection *runListCollection = nullptr; - if (success) { + if (result == PMUSR_SUCCESS) { // feed all the necessary histogramms for the view runListCollection = new PRunListCollection(msrHandler, dataHandler); for (unsigned int i=0; iGetMsrRunList()->size(); i++) { @@ -293,13 +295,14 @@ int main(int argc, char *argv[]) if (!success) { std::cerr << std::endl << ">> musrview **ERROR** Couldn't handle run no " << i << " "; std::cerr << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data(); + result = PMUSR_MSR_RUN_ERROR; break; } } } } - if (success) { + if (result == PMUSR_SUCCESS) { // generate Root application needed for PMusrCanvas if (graphicsOutput || asciiOutput) { argv[argc] = (char*)malloc(16*sizeof(char)); @@ -409,5 +412,5 @@ int main(int argc, char *argv[]) runListCollection = nullptr; } - return PMUSR_SUCCESS; + return result; } From 074d8c77e4ad36a3cccd653546df870a589fb2c9 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 25 Apr 2019 20:30:44 +0200 Subject: [PATCH 3/4] some minor cleanup and update of the copyright info. --- src/musredit_qt5/musredit/PAdmin.cpp | 13 ++++++------- src/musredit_qt5/musredit/PAdmin.h | 2 +- .../musredit/PChangeDefaultPathsDialog.cpp | 2 +- .../musredit/PChangeDefaultPathsDialog.h | 2 +- src/musredit_qt5/musredit/PDumpOutputHandler.cpp | 2 +- src/musredit_qt5/musredit/PDumpOutputHandler.h | 2 +- src/musredit_qt5/musredit/PFindDialog.cpp | 2 +- src/musredit_qt5/musredit/PFindDialog.h | 2 +- src/musredit_qt5/musredit/PFitOutputHandler.cpp | 6 +++--- src/musredit_qt5/musredit/PFitOutputHandler.h | 2 +- .../musredit/PGetAsymmetryRunBlockDialog.cpp | 2 +- .../musredit/PGetAsymmetryRunBlockDialog.h | 2 +- src/musredit_qt5/musredit/PGetDefaultDialog.cpp | 2 +- src/musredit_qt5/musredit/PGetDefaultDialog.h | 2 +- .../musredit/PGetFourierBlockDialog.cpp | 2 +- .../musredit/PGetFunctionsBlockDialog.cpp | 2 +- .../musredit/PGetFunctionsBlockDialog.h | 2 +- .../musredit/PGetMusrFTOptionsDialog.cpp | 2 +- src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.h | 2 +- .../musredit/PGetNonMusrRunBlockDialog.cpp | 2 +- .../musredit/PGetNonMusrRunBlockDialog.h | 2 +- .../musredit/PGetParameterBlockDialog.cpp | 2 +- .../musredit/PGetParameterBlockDialog.h | 2 +- src/musredit_qt5/musredit/PGetPlotBlockDialog.cpp | 2 +- src/musredit_qt5/musredit/PGetPlotBlockDialog.h | 2 +- .../musredit/PGetSingleHistoRunBlockDialog.cpp | 2 +- .../musredit/PGetSingleHistoRunBlockDialog.h | 2 +- src/musredit_qt5/musredit/PGetTheoryBlockDialog.cpp | 2 +- src/musredit_qt5/musredit/PGetTheoryBlockDialog.h | 2 +- src/musredit_qt5/musredit/PGetTitleBlockDialog.cpp | 2 +- src/musredit_qt5/musredit/PGetTitleBlockDialog.h | 2 +- src/musredit_qt5/musredit/PHelp.cpp | 2 +- src/musredit_qt5/musredit/PHelp.h | 2 +- src/musredit_qt5/musredit/PMsr2DataDialog.cpp | 2 +- src/musredit_qt5/musredit/PMsr2DataDialog.h | 2 +- src/musredit_qt5/musredit/PMusrEditAbout.cpp | 2 +- src/musredit_qt5/musredit/PMusrEditAbout.h | 2 +- src/musredit_qt5/musredit/PPrefsDialog.cpp | 2 +- src/musredit_qt5/musredit/PPrefsDialog.h | 2 +- .../musredit/PReplaceConfirmationDialog.cpp | 2 +- .../musredit/PReplaceConfirmationDialog.h | 2 +- src/musredit_qt5/musredit/PReplaceDialog.cpp | 2 +- src/musredit_qt5/musredit/PReplaceDialog.h | 2 +- src/musredit_qt5/musredit/PSubTextEdit.cpp | 2 +- src/musredit_qt5/musredit/PSubTextEdit.h | 2 +- src/musredit_qt5/musredit/main.cpp | 11 +++++------ src/musredit_qt5/musredit/musredit.h | 2 +- 47 files changed, 58 insertions(+), 60 deletions(-) diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index 19f5288d..1f53aa6b 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -29,7 +29,6 @@ #include #include -using namespace std; #include #include @@ -800,7 +799,7 @@ int PAdmin::savePrefs(QString pref_fln) QVector data; QFile file(fln); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl; + std::cerr << std::endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << std::endl; return 1; } QTextStream fin(&file); @@ -879,7 +878,7 @@ int PAdmin::savePrefs(QString pref_fln) // write prefs file.setFileName(pref_fln); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - cerr << endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << pref_fln.toLatin1().data() << " for writing." << endl; + std::cerr << std::endl << ">> PAdmin::savePrefs: **ERROR** Cannot open " << pref_fln.toLatin1().data() << " for writing." << std::endl; return 0; } fin.setDevice(&file); @@ -933,7 +932,7 @@ void PAdmin::saveRecentFiles() QVector data; QFile file(fln); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl; + std::cerr << std::endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << std::endl; return; } QTextStream fin(&file); @@ -958,7 +957,7 @@ void PAdmin::saveRecentFiles() } if (i == data.size()) { - cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** " << fln.toLatin1().data() << " seems to be corrupt." << endl; + std::cerr << std::endl << ">> PAdmin::saveRecentFile: **ERROR** " << fln.toLatin1().data() << " seems to be corrupt." << std::endl; return; } i++; @@ -968,7 +967,7 @@ void PAdmin::saveRecentFiles() } if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - cerr << endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << endl; + std::cerr << std::endl << ">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() << " for reading." << std::endl; return; } fin.setDevice(&file); diff --git a/src/musredit_qt5/musredit/PAdmin.h b/src/musredit_qt5/musredit/PAdmin.h index 0368a90b..a05a72e7 100644 --- a/src/musredit_qt5/musredit/PAdmin.h +++ b/src/musredit_qt5/musredit/PAdmin.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp index a69aa86f..1e84434e 100644 --- a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp +++ b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2017 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.h b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.h index f6603825..0eb73061 100644 --- a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.h +++ b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2017 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PDumpOutputHandler.cpp b/src/musredit_qt5/musredit/PDumpOutputHandler.cpp index efe7af1f..2bddcea2 100644 --- a/src/musredit_qt5/musredit/PDumpOutputHandler.cpp +++ b/src/musredit_qt5/musredit/PDumpOutputHandler.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2012-2016 by Andreas Suter * + * Copyright (C) 2012-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PDumpOutputHandler.h b/src/musredit_qt5/musredit/PDumpOutputHandler.h index fa9813b4..99738b83 100644 --- a/src/musredit_qt5/musredit/PDumpOutputHandler.h +++ b/src/musredit_qt5/musredit/PDumpOutputHandler.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2012-2016 by Andreas Suter * + * Copyright (C) 2012-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PFindDialog.cpp b/src/musredit_qt5/musredit/PFindDialog.cpp index ef91999a..d8101ee6 100644 --- a/src/musredit_qt5/musredit/PFindDialog.cpp +++ b/src/musredit_qt5/musredit/PFindDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PFindDialog.h b/src/musredit_qt5/musredit/PFindDialog.h index 9b575ee2..b3348183 100644 --- a/src/musredit_qt5/musredit/PFindDialog.h +++ b/src/musredit_qt5/musredit/PFindDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PFitOutputHandler.cpp b/src/musredit_qt5/musredit/PFitOutputHandler.cpp index 63828b86..63953bf1 100644 --- a/src/musredit_qt5/musredit/PFitOutputHandler.cpp +++ b/src/musredit_qt5/musredit/PFitOutputHandler.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -83,7 +83,7 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QVector if ( !fProc->waitForStarted() ) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, + QMessageBox::critical( nullptr, tr("Fatal error"), msg, tr("Quit") ); @@ -114,7 +114,7 @@ PFitOutputHandler::~PFitOutputHandler() } if (fProc) { delete fProc; - fProc = 0; + fProc = nullptr; } } diff --git a/src/musredit_qt5/musredit/PFitOutputHandler.h b/src/musredit_qt5/musredit/PFitOutputHandler.h index 1ece29bd..749558e1 100644 --- a/src/musredit_qt5/musredit/PFitOutputHandler.h +++ b/src/musredit_qt5/musredit/PFitOutputHandler.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.cpp b/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.cpp index b4503eb8..14d74570 100644 --- a/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.h b/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.h index 836274ab..c6c2cce3 100644 --- a/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetAsymmetryRunBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetDefaultDialog.cpp b/src/musredit_qt5/musredit/PGetDefaultDialog.cpp index ae0da191..0c5ae759 100644 --- a/src/musredit_qt5/musredit/PGetDefaultDialog.cpp +++ b/src/musredit_qt5/musredit/PGetDefaultDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetDefaultDialog.h b/src/musredit_qt5/musredit/PGetDefaultDialog.h index 404021d2..8ef8f216 100644 --- a/src/musredit_qt5/musredit/PGetDefaultDialog.h +++ b/src/musredit_qt5/musredit/PGetDefaultDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetFourierBlockDialog.cpp b/src/musredit_qt5/musredit/PGetFourierBlockDialog.cpp index 8455fd78..3e7650fd 100644 --- a/src/musredit_qt5/musredit/PGetFourierBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetFourierBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.cpp b/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.cpp index 7d706578..ff144eb4 100644 --- a/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.h b/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.h index ead1e2f0..c70427f6 100644 --- a/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetFunctionsBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.cpp b/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.cpp index 3e63c666..f92114bb 100644 --- a/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.cpp +++ b/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.h b/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.h index e00366e3..bc2d5421 100644 --- a/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.h +++ b/src/musredit_qt5/musredit/PGetMusrFTOptionsDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.cpp b/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.cpp index c8814c40..8c042fd9 100644 --- a/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.h b/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.h index 7faa842d..9ed00d9f 100644 --- a/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetNonMusrRunBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetParameterBlockDialog.cpp b/src/musredit_qt5/musredit/PGetParameterBlockDialog.cpp index e5f4abbe..2cc64e4b 100644 --- a/src/musredit_qt5/musredit/PGetParameterBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetParameterBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetParameterBlockDialog.h b/src/musredit_qt5/musredit/PGetParameterBlockDialog.h index c8c74ee6..6e235bef 100644 --- a/src/musredit_qt5/musredit/PGetParameterBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetParameterBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetPlotBlockDialog.cpp b/src/musredit_qt5/musredit/PGetPlotBlockDialog.cpp index d2df92a4..ce10a31d 100644 --- a/src/musredit_qt5/musredit/PGetPlotBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetPlotBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetPlotBlockDialog.h b/src/musredit_qt5/musredit/PGetPlotBlockDialog.h index cf662945..ba545cb9 100644 --- a/src/musredit_qt5/musredit/PGetPlotBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetPlotBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.cpp b/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.cpp index 9e9b369e..a28fe371 100644 --- a/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.h b/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.h index 0fd094cd..5b2701a3 100644 --- a/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetSingleHistoRunBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetTheoryBlockDialog.cpp b/src/musredit_qt5/musredit/PGetTheoryBlockDialog.cpp index 1683c78a..8c4d05e6 100644 --- a/src/musredit_qt5/musredit/PGetTheoryBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetTheoryBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetTheoryBlockDialog.h b/src/musredit_qt5/musredit/PGetTheoryBlockDialog.h index 163893e8..f6d3c2d8 100644 --- a/src/musredit_qt5/musredit/PGetTheoryBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetTheoryBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetTitleBlockDialog.cpp b/src/musredit_qt5/musredit/PGetTitleBlockDialog.cpp index 3ecf4a98..87956385 100644 --- a/src/musredit_qt5/musredit/PGetTitleBlockDialog.cpp +++ b/src/musredit_qt5/musredit/PGetTitleBlockDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PGetTitleBlockDialog.h b/src/musredit_qt5/musredit/PGetTitleBlockDialog.h index a9a6fd04..e9eb1853 100644 --- a/src/musredit_qt5/musredit/PGetTitleBlockDialog.h +++ b/src/musredit_qt5/musredit/PGetTitleBlockDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PHelp.cpp b/src/musredit_qt5/musredit/PHelp.cpp index ca233b28..facd7da8 100644 --- a/src/musredit_qt5/musredit/PHelp.cpp +++ b/src/musredit_qt5/musredit/PHelp.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PHelp.h b/src/musredit_qt5/musredit/PHelp.h index 4a45db25..19a276cc 100644 --- a/src/musredit_qt5/musredit/PHelp.h +++ b/src/musredit_qt5/musredit/PHelp.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PMsr2DataDialog.cpp b/src/musredit_qt5/musredit/PMsr2DataDialog.cpp index 6a1c66fc..94a4f89c 100644 --- a/src/musredit_qt5/musredit/PMsr2DataDialog.cpp +++ b/src/musredit_qt5/musredit/PMsr2DataDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PMsr2DataDialog.h b/src/musredit_qt5/musredit/PMsr2DataDialog.h index 28099740..88a05959 100644 --- a/src/musredit_qt5/musredit/PMsr2DataDialog.h +++ b/src/musredit_qt5/musredit/PMsr2DataDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PMusrEditAbout.cpp b/src/musredit_qt5/musredit/PMusrEditAbout.cpp index f918ed9e..40ba50d7 100644 --- a/src/musredit_qt5/musredit/PMusrEditAbout.cpp +++ b/src/musredit_qt5/musredit/PMusrEditAbout.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PMusrEditAbout.h b/src/musredit_qt5/musredit/PMusrEditAbout.h index f9456c60..a5915265 100644 --- a/src/musredit_qt5/musredit/PMusrEditAbout.h +++ b/src/musredit_qt5/musredit/PMusrEditAbout.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PPrefsDialog.cpp b/src/musredit_qt5/musredit/PPrefsDialog.cpp index 48ceca65..7660e885 100644 --- a/src/musredit_qt5/musredit/PPrefsDialog.cpp +++ b/src/musredit_qt5/musredit/PPrefsDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PPrefsDialog.h b/src/musredit_qt5/musredit/PPrefsDialog.h index ffaca305..f0f0c878 100644 --- a/src/musredit_qt5/musredit/PPrefsDialog.h +++ b/src/musredit_qt5/musredit/PPrefsDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2017 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PReplaceConfirmationDialog.cpp b/src/musredit_qt5/musredit/PReplaceConfirmationDialog.cpp index 9cf2cf42..20e7bea2 100644 --- a/src/musredit_qt5/musredit/PReplaceConfirmationDialog.cpp +++ b/src/musredit_qt5/musredit/PReplaceConfirmationDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PReplaceConfirmationDialog.h b/src/musredit_qt5/musredit/PReplaceConfirmationDialog.h index a213c830..86611ec1 100644 --- a/src/musredit_qt5/musredit/PReplaceConfirmationDialog.h +++ b/src/musredit_qt5/musredit/PReplaceConfirmationDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PReplaceDialog.cpp b/src/musredit_qt5/musredit/PReplaceDialog.cpp index 1ab29e5d..11a6322d 100644 --- a/src/musredit_qt5/musredit/PReplaceDialog.cpp +++ b/src/musredit_qt5/musredit/PReplaceDialog.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PReplaceDialog.h b/src/musredit_qt5/musredit/PReplaceDialog.h index 8f8ab8a5..b0534239 100644 --- a/src/musredit_qt5/musredit/PReplaceDialog.h +++ b/src/musredit_qt5/musredit/PReplaceDialog.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PSubTextEdit.cpp b/src/musredit_qt5/musredit/PSubTextEdit.cpp index 7c705d9d..542adf48 100644 --- a/src/musredit_qt5/musredit/PSubTextEdit.cpp +++ b/src/musredit_qt5/musredit/PSubTextEdit.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/PSubTextEdit.h b/src/musredit_qt5/musredit/PSubTextEdit.h index 0c774f50..5836800c 100644 --- a/src/musredit_qt5/musredit/PSubTextEdit.h +++ b/src/musredit_qt5/musredit/PSubTextEdit.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2016 by Andreas Suter * + * Copyright (C) 2009-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/musredit_qt5/musredit/main.cpp b/src/musredit_qt5/musredit/main.cpp index c4132ab9..76dfe392 100644 --- a/src/musredit_qt5/musredit/main.cpp +++ b/src/musredit_qt5/musredit/main.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -28,7 +28,6 @@ ***************************************************************************/ #include -using namespace std; #include @@ -49,12 +48,12 @@ int main( int argc, char ** argv ) if (argc == 2) { if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) { - cout << endl << "usage: musredit [] | -h, --help | -v, --version"; - cout << endl << endl; + std::cout << std::endl << "usage: musredit [] | -h, --help | -v, --version"; + std::cout << std::endl << std::endl; return 0; } else if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { - cout << endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1; - cout << endl << endl; + std::cout << std::endl << "musredit git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1; + std::cout << std::endl << std::endl; return 0; } } diff --git a/src/musredit_qt5/musredit/musredit.h b/src/musredit_qt5/musredit/musredit.h index 680b8e3c..8cdbb2f1 100644 --- a/src/musredit_qt5/musredit/musredit.h +++ b/src/musredit_qt5/musredit/musredit.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * From dae9ef0ffba45f2fb9bb97a1aebb8a2aea9113e7 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 25 Apr 2019 20:33:43 +0200 Subject: [PATCH 4/4] some minor improvement concerning the start of musrview for cases where the msr-file is corrupted, the data file cannot be read, etc. --- src/musredit_qt5/musredit/PTextEdit.cpp | 167 +++++++++++++----------- src/musredit_qt5/musredit/PTextEdit.h | 6 +- 2 files changed, 96 insertions(+), 77 deletions(-) diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index 7361e90e..518ed9bd 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -29,7 +29,6 @@ #include #include -using namespace std; #include #include @@ -94,17 +93,17 @@ PTextEdit::PTextEdit( QWidget *parent, Qt::WindowFlags f ) // enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime fFileSystemWatcherActive = true; fFileSystemWatcher = new QFileSystemWatcher(); - if (fFileSystemWatcher == 0) { + if (fFileSystemWatcher == nullptr) { QMessageBox::information(this, "**ERROR**", "Couldn't invoke QFileSystemWatcher!"); } else { connect( fFileSystemWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&))); } // initialize stuff - fMusrT0Action = 0; + fMusrT0Action = nullptr; - fMsr2DataParam = 0; - fFindReplaceData = 0, + fMsr2DataParam = nullptr; + fFindReplaceData = nullptr; // setup menus setupFileActions(); @@ -150,19 +149,19 @@ void PTextEdit::aboutToQuit() { if (fAdmin) { delete fAdmin; - fAdmin = 0; + fAdmin = nullptr; } if (fMusrT0Action) { delete fMusrT0Action; - fMusrT0Action = 0; + fMusrT0Action = nullptr; } if (fMsr2DataParam) { delete fMsr2DataParam; - fMsr2DataParam = 0; + fMsr2DataParam = nullptr; } if (fFindReplaceData) { delete fFindReplaceData; - fFindReplaceData = 0; + fFindReplaceData = nullptr; } } @@ -580,7 +579,7 @@ void PTextEdit::setupTextActions() connect( fComboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); QLineEdit *edit = fComboFont->lineEdit(); - if (edit == 0) { + if (edit == nullptr) { return; } edit->setText( fAdmin->getFontName() ); @@ -595,7 +594,7 @@ void PTextEdit::setupTextActions() connect( fComboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); edit = fComboSize->lineEdit(); - if (edit == 0) { + if (edit == nullptr) { return; } edit->setText( QString("%1").arg(fAdmin->getFontSize()) ); @@ -900,11 +899,11 @@ PSubTextEdit *PTextEdit::currentEditor() const { if ( fTabWidget->currentWidget() ) { if (fTabWidget->currentWidget()->inherits( "PSubTextEdit" )) { - return (PSubTextEdit*)fTabWidget->currentWidget(); + return dynamic_cast(fTabWidget->currentWidget()); } } - return 0; + return nullptr; } //---------------------------------------------------------------------------------------------------- @@ -1190,7 +1189,7 @@ void PTextEdit::fileOpenPrefs() if (fAdmin->loadPrefs(fln)) { msg = QString("Prefs from '") + fln + QString("' loaded."); - QMessageBox::information(0, "Info", msg); + QMessageBox::information(nullptr, "Info", msg); } } @@ -1277,7 +1276,7 @@ void PTextEdit::fileSavePrefs() if ( !fln.isEmpty() ) { fAdmin->savePrefs(fln); msg = QString("Prefs to '") + fln + QString("' saved."); - QMessageBox::information(0, "Info", msg); + QMessageBox::information(nullptr, "Info", msg); } } @@ -1308,7 +1307,7 @@ void PTextEdit::filePrint() int yPos = 0; // y-position for each line QFontMetrics fm = p.fontMetrics(); int dpiy = printer.logicalDpiY(); - int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins + int margin = static_cast( (2/2.54)*dpiy ); // 2 cm margins // print msr-file QString fln = *fFilenames.find(currentEditor()); @@ -1568,7 +1567,7 @@ void PTextEdit::editFind() return; // check if first time called, and if yes create find and replace data structure - if (fFindReplaceData == 0) { + if (fFindReplaceData == nullptr) { fFindReplaceData = new PFindReplaceData(); fFindReplaceData->findText = QString(""); fFindReplaceData->replaceText = QString(""); @@ -1580,13 +1579,13 @@ void PTextEdit::editFind() fFindReplaceData->promptOnReplace = true; } - if (fFindReplaceData == 0) { + if (fFindReplaceData == nullptr) { QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); return; } PFindDialog *dlg = new PFindDialog(fFindReplaceData, currentEditor()->textCursor().hasSelection()); - if (dlg == 0) { + if (dlg == nullptr) { QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); return; } @@ -1601,13 +1600,13 @@ void PTextEdit::editFind() fFindReplaceData = dlg->getData(); delete dlg; - dlg = 0; + dlg = nullptr; // try to find the search text if (!fFindReplaceData->fromCursor) currentEditor()->textCursor().setPosition(0); - QTextDocument::FindFlags flags = 0; + QTextDocument::FindFlags flags = nullptr; if (fFindReplaceData->caseSensitive) flags |= QTextDocument::FindCaseSensitively; else if (fFindReplaceData->findBackwards) @@ -1624,7 +1623,7 @@ void PTextEdit::editFind() */ void PTextEdit::editFindNext() { - QTextDocument::FindFlags flags = 0; + QTextDocument::FindFlags flags = nullptr; if (fFindReplaceData->caseSensitive) flags |= QTextDocument::FindCaseSensitively; else if (fFindReplaceData->wholeWordsOnly) @@ -1639,7 +1638,7 @@ void PTextEdit::editFindNext() */ void PTextEdit::editFindPrevious() { - QTextDocument::FindFlags flags = 0; + QTextDocument::FindFlags flags = nullptr; if (fFindReplaceData->caseSensitive) flags |= QTextDocument::FindCaseSensitively; else if (fFindReplaceData->wholeWordsOnly) @@ -1660,7 +1659,7 @@ void PTextEdit::editFindAndReplace() return; // check if first time called, and if yes create find and replace data structure - if (fFindReplaceData == 0) { + if (fFindReplaceData == nullptr) { fFindReplaceData = new PFindReplaceData(); fFindReplaceData->findText = QString(""); fFindReplaceData->replaceText = QString(""); @@ -1672,13 +1671,13 @@ void PTextEdit::editFindAndReplace() fFindReplaceData->promptOnReplace = true; } - if (fFindReplaceData == 0) { + if (fFindReplaceData == nullptr) { QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find&replace data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); return; } PReplaceDialog *dlg = new PReplaceDialog(fFindReplaceData, currentEditor()->textCursor().hasSelection()); - if (dlg == 0) { + if (dlg == nullptr) { QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find&replace dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); return; } @@ -1693,7 +1692,7 @@ void PTextEdit::editFindAndReplace() fFindReplaceData = dlg->getData(); delete dlg; - dlg = 0; + dlg = nullptr; if (fFindReplaceData->promptOnReplace) { editFindNext(); @@ -1853,7 +1852,7 @@ void PTextEdit::musrWiz() QProcess *proc = new QProcess(this); if (proc == nullptr) { - QMessageBox::critical(0, "**ERROR**", "Couldn't invoke QProcess!"); + QMessageBox::critical(nullptr, "**ERROR**", "Couldn't invoke QProcess!"); return; } @@ -1870,10 +1869,10 @@ void PTextEdit::musrWiz() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } @@ -2033,7 +2032,7 @@ void PTextEdit::musrFit() */ void PTextEdit::musrMsr2Data() { - if (fMsr2DataParam == 0) { + if (fMsr2DataParam == nullptr) { fMsr2DataParam = new PMsr2DataParam(); *fMsr2DataParam = fAdmin->getMsr2DataParam(); } @@ -2046,7 +2045,7 @@ void PTextEdit::musrMsr2Data() PMsr2DataDialog *dlg = new PMsr2DataDialog(fMsr2DataParam, fAdmin->getHelpUrl("msr2data")); - if (dlg == 0) { + if (dlg == nullptr) { QMessageBox::critical(this, "**ERROR**", "Couldn't invoke msr2data dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); return; } @@ -2361,7 +2360,7 @@ void PTextEdit::musrMsr2Data() } delete dlg; - dlg = 0; + dlg = nullptr; fileSystemWatcherActivation(); } @@ -2410,6 +2409,7 @@ void PTextEdit::musrView() arg << "-a"; QProcess *proc = new QProcess(this); + connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(musrViewFinished(int, QProcess::ExitStatus))); // make sure that the system environment variables are properly set QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -2420,17 +2420,34 @@ void PTextEdit::musrView() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } //---------------------------------------------------------------------------------------------------- /** - *

Callse musrt0 . + *

Checks if musrview terminated with error, and if yes pop up a message box. + * @param exitCode + */ +void PTextEdit::musrViewFinished(int exitCode, QProcess::ExitStatus) +{ + if (exitCode != 0) { + QString msg = QString("musrview failed. Possible reasons:\n"); + msg += QString("* corrupted msr-file.\n"); + msg += QString("* cannot read data-file.\n"); + msg += QString("* many more things can go wrong.\n"); + msg += QString("Please check!"); + QMessageBox::critical(nullptr, tr("Fatal Error"), msg, tr("Quit")); + } +} + +//---------------------------------------------------------------------------------------------------- +/** + *

Calls musrt0 . */ void PTextEdit::musrT0() { @@ -2474,10 +2491,10 @@ void PTextEdit::musrT0() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } @@ -2492,7 +2509,7 @@ void PTextEdit::musrFT() PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find( currentEditor() ), fMusrFTPrevCmd, fAdmin->getHelpUrl("musrFT")); - if (dlg == 0) { + if (dlg == nullptr) { QMessageBox::critical(this, "**ERROR** musrFT", "Couldn't invoke musrFT Options Dialog."); return; } @@ -2510,16 +2527,16 @@ void PTextEdit::musrFT() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } delete dlg; - dlg = 0; + dlg = nullptr; } //---------------------------------------------------------------------------------------------------- @@ -2530,7 +2547,7 @@ void PTextEdit::musrPrefs() { PPrefsDialog *dlg = new PPrefsDialog(fAdmin); - if (dlg == 0) { + if (dlg == nullptr) { QMessageBox::critical(this, "**ERROR** musrPrefs", "Couldn't invoke Preferences Dialog."); return; } @@ -2558,7 +2575,7 @@ void PTextEdit::musrPrefs() } delete dlg; - dlg = 0; + dlg = nullptr; } //---------------------------------------------------------------------------------------------------- @@ -2599,7 +2616,7 @@ void PTextEdit::musrSetSteps() QProcess *proc = new QProcess(this); if (proc == nullptr) { - QMessageBox::critical(0, "**ERROR**", "Couldn't invoke QProcess!"); + QMessageBox::critical(nullptr, "**ERROR**", "Couldn't invoke QProcess!"); return; } @@ -2616,10 +2633,10 @@ void PTextEdit::musrSetSteps() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd[0]); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } @@ -2668,42 +2685,42 @@ void PTextEdit::musrSwapMsrMlog() fileSave(); } - QMessageBox::information(0, "INFO", QString("Will now swap files: %1 <-> %2").arg(currentFileName).arg(swapFileName)); + QMessageBox::information(nullptr, "INFO", QString("Will now swap files: %1 <-> %2").arg(currentFileName).arg(swapFileName)); // swap files // copy currentFile -> tempFile if (QFile::exists(tempFileName)) { if (!QFile::remove(tempFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(tempFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to remove %1").arg(tempFileName)); return; } } if (!QFile::copy(currentFileName, tempFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(currentFileName).arg(tempFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to copy %1 -> %2").arg(currentFileName).arg(tempFileName)); return; } // copy swapFile -> currentFile if (!QFile::remove(currentFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(currentFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to remove %1").arg(currentFileName)); return; } if (!QFile::copy(swapFileName, currentFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(swapFileName).arg(currentFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to copy %1 -> %2").arg(swapFileName).arg(currentFileName)); return; } // copy tempFile -> swapFile if (!QFile::remove(swapFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(swapFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to remove %1").arg(swapFileName)); return; } if (!QFile::copy(tempFileName, swapFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(tempFileName).arg(swapFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to copy %1 -> %2").arg(tempFileName).arg(swapFileName)); return; } // clean up if (!QFile::remove(tempFileName)) { - QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(tempFileName)); + QMessageBox::critical(nullptr, "ERROR", QString("failed to remove %1").arg(tempFileName)); return; } @@ -2777,10 +2794,10 @@ void PTextEdit::mupp() if (!proc->waitForStarted()) { // error handling QString msg(tr("Could not execute the output command: ")+cmd); - QMessageBox::critical( 0, - tr("Fatal error"), - msg, - tr("Quit") ); + QMessageBox::critical( nullptr, + tr("Fatal error"), + msg, + tr("Quit") ); return; } } @@ -2824,7 +2841,7 @@ void PTextEdit::helpAboutQt() void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus == QProcess::CrashExit) { - QMessageBox::critical(0, "**FATAL**", "musrWiz returned CrashExit."); + QMessageBox::critical(nullptr, "**FATAL**", "musrWiz returned CrashExit."); return; } @@ -2837,10 +2854,10 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus) QString pathName = procEnv.value("HOME", ""); pathName += "/.musrfit/musredit/musrWiz.log"; QString errMsg; - ifstream fin(pathName.toLatin1().data(), ifstream::in); + std::ifstream fin(pathName.toLatin1().data(), std::ifstream::in); if (!fin.is_open()) { errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't read %1 file.").arg(pathName); - QMessageBox::critical(0, "**ERROR**", errMsg); + QMessageBox::critical(nullptr, "**ERROR**", errMsg); return; } char line[128]; @@ -2875,7 +2892,7 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus) QFile logFile(pathName); if (!logFile.remove()) { errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't delete %1 file.").arg(pathName); - QMessageBox::critical(0, "**ERROR**", errMsg); + QMessageBox::critical(nullptr, "**ERROR**", errMsg); } } @@ -2888,7 +2905,7 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus) void PTextEdit::exitStatusMusrSetSteps(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus == QProcess::CrashExit) { - QMessageBox::critical(0, "**FATAL**", "musrStep returned CrashExit."); + QMessageBox::critical(nullptr, "**FATAL**", "musrStep returned CrashExit."); return; } diff --git a/src/musredit_qt5/musredit/PTextEdit.h b/src/musredit_qt5/musredit/PTextEdit.h index 3fc8e21a..ec64b2c4 100644 --- a/src/musredit_qt5/musredit/PTextEdit.h +++ b/src/musredit_qt5/musredit/PTextEdit.h @@ -8,7 +8,7 @@ *****************************************************************************/ /*************************************************************************** - * Copyright (C) 2010-2016 by Andreas Suter * + * Copyright (C) 2010-2019 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -63,7 +64,7 @@ class PTextEdit : public QMainWindow Q_OBJECT public: - PTextEdit( QWidget *parent = 0, Qt::WindowFlags f = 0 ); + PTextEdit( QWidget *parent = nullptr, Qt::WindowFlags f = nullptr ); virtual ~PTextEdit() {} public slots: @@ -132,6 +133,7 @@ private slots: void musrFit(); void musrMsr2Data(); void musrView(); + void musrViewFinished(int, QProcess::ExitStatus); void musrT0(); void musrFT(); void musrPrefs();