some minor improvement concerning the start of musrview for cases where the msr-file is corrupted, the data file cannot be read, etc.

This commit is contained in:
suter_a 2019-04-25 20:33:43 +02:00
parent 306e555311
commit ed365c016e
2 changed files with 96 additions and 77 deletions

View File

@ -8,7 +8,7 @@
*****************************************************************************/ *****************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2010-2016 by Andreas Suter * * Copyright (C) 2010-2019 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -29,7 +29,6 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace std;
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
@ -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 // enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime
fFileSystemWatcherActive = true; fFileSystemWatcherActive = true;
fFileSystemWatcher = new QFileSystemWatcher(); fFileSystemWatcher = new QFileSystemWatcher();
if (fFileSystemWatcher == 0) { if (fFileSystemWatcher == nullptr) {
QMessageBox::information(this, "**ERROR**", "Couldn't invoke QFileSystemWatcher!"); QMessageBox::information(this, "**ERROR**", "Couldn't invoke QFileSystemWatcher!");
} else { } else {
connect( fFileSystemWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&))); connect( fFileSystemWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&)));
} }
// initialize stuff // initialize stuff
fMusrT0Action = 0; fMusrT0Action = nullptr;
fMsr2DataParam = 0; fMsr2DataParam = nullptr;
fFindReplaceData = 0, fFindReplaceData = nullptr;
// setup menus // setup menus
setupFileActions(); setupFileActions();
@ -150,19 +149,19 @@ void PTextEdit::aboutToQuit()
{ {
if (fAdmin) { if (fAdmin) {
delete fAdmin; delete fAdmin;
fAdmin = 0; fAdmin = nullptr;
} }
if (fMusrT0Action) { if (fMusrT0Action) {
delete fMusrT0Action; delete fMusrT0Action;
fMusrT0Action = 0; fMusrT0Action = nullptr;
} }
if (fMsr2DataParam) { if (fMsr2DataParam) {
delete fMsr2DataParam; delete fMsr2DataParam;
fMsr2DataParam = 0; fMsr2DataParam = nullptr;
} }
if (fFindReplaceData) { if (fFindReplaceData) {
delete fFindReplaceData; delete fFindReplaceData;
fFindReplaceData = 0; fFindReplaceData = nullptr;
} }
} }
@ -580,7 +579,7 @@ void PTextEdit::setupTextActions()
connect( fComboFont, SIGNAL( activated( const QString & ) ), connect( fComboFont, SIGNAL( activated( const QString & ) ),
this, SLOT( textFamily( const QString & ) ) ); this, SLOT( textFamily( const QString & ) ) );
QLineEdit *edit = fComboFont->lineEdit(); QLineEdit *edit = fComboFont->lineEdit();
if (edit == 0) { if (edit == nullptr) {
return; return;
} }
edit->setText( fAdmin->getFontName() ); edit->setText( fAdmin->getFontName() );
@ -595,7 +594,7 @@ void PTextEdit::setupTextActions()
connect( fComboSize, SIGNAL( activated( const QString & ) ), connect( fComboSize, SIGNAL( activated( const QString & ) ),
this, SLOT( textSize( const QString & ) ) ); this, SLOT( textSize( const QString & ) ) );
edit = fComboSize->lineEdit(); edit = fComboSize->lineEdit();
if (edit == 0) { if (edit == nullptr) {
return; return;
} }
edit->setText( QString("%1").arg(fAdmin->getFontSize()) ); edit->setText( QString("%1").arg(fAdmin->getFontSize()) );
@ -900,11 +899,11 @@ PSubTextEdit *PTextEdit::currentEditor() const
{ {
if ( fTabWidget->currentWidget() ) { if ( fTabWidget->currentWidget() ) {
if (fTabWidget->currentWidget()->inherits( "PSubTextEdit" )) { if (fTabWidget->currentWidget()->inherits( "PSubTextEdit" )) {
return (PSubTextEdit*)fTabWidget->currentWidget(); return dynamic_cast<PSubTextEdit*>(fTabWidget->currentWidget());
} }
} }
return 0; return nullptr;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1190,7 +1189,7 @@ void PTextEdit::fileOpenPrefs()
if (fAdmin->loadPrefs(fln)) { if (fAdmin->loadPrefs(fln)) {
msg = QString("Prefs from '") + fln + QString("' loaded."); 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() ) { if ( !fln.isEmpty() ) {
fAdmin->savePrefs(fln); fAdmin->savePrefs(fln);
msg = QString("Prefs to '") + fln + QString("' saved."); 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 int yPos = 0; // y-position for each line
QFontMetrics fm = p.fontMetrics(); QFontMetrics fm = p.fontMetrics();
int dpiy = printer.logicalDpiY(); int dpiy = printer.logicalDpiY();
int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins int margin = static_cast<int>( (2/2.54)*dpiy ); // 2 cm margins
// print msr-file // print msr-file
QString fln = *fFilenames.find(currentEditor()); QString fln = *fFilenames.find(currentEditor());
@ -1568,7 +1567,7 @@ void PTextEdit::editFind()
return; return;
// check if first time called, and if yes create find and replace data structure // check if first time called, and if yes create find and replace data structure
if (fFindReplaceData == 0) { if (fFindReplaceData == nullptr) {
fFindReplaceData = new PFindReplaceData(); fFindReplaceData = new PFindReplaceData();
fFindReplaceData->findText = QString(""); fFindReplaceData->findText = QString("");
fFindReplaceData->replaceText = QString(""); fFindReplaceData->replaceText = QString("");
@ -1580,13 +1579,13 @@ void PTextEdit::editFind()
fFindReplaceData->promptOnReplace = true; fFindReplaceData->promptOnReplace = true;
} }
if (fFindReplaceData == 0) { if (fFindReplaceData == nullptr) {
QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return; return;
} }
PFindDialog *dlg = new PFindDialog(fFindReplaceData, currentEditor()->textCursor().hasSelection()); 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); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return; return;
} }
@ -1601,13 +1600,13 @@ void PTextEdit::editFind()
fFindReplaceData = dlg->getData(); fFindReplaceData = dlg->getData();
delete dlg; delete dlg;
dlg = 0; dlg = nullptr;
// try to find the search text // try to find the search text
if (!fFindReplaceData->fromCursor) if (!fFindReplaceData->fromCursor)
currentEditor()->textCursor().setPosition(0); currentEditor()->textCursor().setPosition(0);
QTextDocument::FindFlags flags = 0; QTextDocument::FindFlags flags = nullptr;
if (fFindReplaceData->caseSensitive) if (fFindReplaceData->caseSensitive)
flags |= QTextDocument::FindCaseSensitively; flags |= QTextDocument::FindCaseSensitively;
else if (fFindReplaceData->findBackwards) else if (fFindReplaceData->findBackwards)
@ -1624,7 +1623,7 @@ void PTextEdit::editFind()
*/ */
void PTextEdit::editFindNext() void PTextEdit::editFindNext()
{ {
QTextDocument::FindFlags flags = 0; QTextDocument::FindFlags flags = nullptr;
if (fFindReplaceData->caseSensitive) if (fFindReplaceData->caseSensitive)
flags |= QTextDocument::FindCaseSensitively; flags |= QTextDocument::FindCaseSensitively;
else if (fFindReplaceData->wholeWordsOnly) else if (fFindReplaceData->wholeWordsOnly)
@ -1639,7 +1638,7 @@ void PTextEdit::editFindNext()
*/ */
void PTextEdit::editFindPrevious() void PTextEdit::editFindPrevious()
{ {
QTextDocument::FindFlags flags = 0; QTextDocument::FindFlags flags = nullptr;
if (fFindReplaceData->caseSensitive) if (fFindReplaceData->caseSensitive)
flags |= QTextDocument::FindCaseSensitively; flags |= QTextDocument::FindCaseSensitively;
else if (fFindReplaceData->wholeWordsOnly) else if (fFindReplaceData->wholeWordsOnly)
@ -1660,7 +1659,7 @@ void PTextEdit::editFindAndReplace()
return; return;
// check if first time called, and if yes create find and replace data structure // check if first time called, and if yes create find and replace data structure
if (fFindReplaceData == 0) { if (fFindReplaceData == nullptr) {
fFindReplaceData = new PFindReplaceData(); fFindReplaceData = new PFindReplaceData();
fFindReplaceData->findText = QString(""); fFindReplaceData->findText = QString("");
fFindReplaceData->replaceText = QString(""); fFindReplaceData->replaceText = QString("");
@ -1672,13 +1671,13 @@ void PTextEdit::editFindAndReplace()
fFindReplaceData->promptOnReplace = true; 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); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find&replace data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return; return;
} }
PReplaceDialog *dlg = new PReplaceDialog(fFindReplaceData, currentEditor()->textCursor().hasSelection()); 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); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find&replace dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return; return;
} }
@ -1693,7 +1692,7 @@ void PTextEdit::editFindAndReplace()
fFindReplaceData = dlg->getData(); fFindReplaceData = dlg->getData();
delete dlg; delete dlg;
dlg = 0; dlg = nullptr;
if (fFindReplaceData->promptOnReplace) { if (fFindReplaceData->promptOnReplace) {
editFindNext(); editFindNext();
@ -1853,7 +1852,7 @@ void PTextEdit::musrWiz()
QProcess *proc = new QProcess(this); QProcess *proc = new QProcess(this);
if (proc == nullptr) { if (proc == nullptr) {
QMessageBox::critical(0, "**ERROR**", "Couldn't invoke QProcess!"); QMessageBox::critical(nullptr, "**ERROR**", "Couldn't invoke QProcess!");
return; return;
} }
@ -1870,10 +1869,10 @@ void PTextEdit::musrWiz()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]); QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
@ -2033,7 +2032,7 @@ void PTextEdit::musrFit()
*/ */
void PTextEdit::musrMsr2Data() void PTextEdit::musrMsr2Data()
{ {
if (fMsr2DataParam == 0) { if (fMsr2DataParam == nullptr) {
fMsr2DataParam = new PMsr2DataParam(); fMsr2DataParam = new PMsr2DataParam();
*fMsr2DataParam = fAdmin->getMsr2DataParam(); *fMsr2DataParam = fAdmin->getMsr2DataParam();
} }
@ -2046,7 +2045,7 @@ void PTextEdit::musrMsr2Data()
PMsr2DataDialog *dlg = new PMsr2DataDialog(fMsr2DataParam, fAdmin->getHelpUrl("msr2data")); 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); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke msr2data dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return; return;
} }
@ -2361,7 +2360,7 @@ void PTextEdit::musrMsr2Data()
} }
delete dlg; delete dlg;
dlg = 0; dlg = nullptr;
fileSystemWatcherActivation(); fileSystemWatcherActivation();
} }
@ -2410,6 +2409,7 @@ void PTextEdit::musrView()
arg << "-a"; arg << "-a";
QProcess *proc = new QProcess(this); 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 // make sure that the system environment variables are properly set
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
@ -2422,17 +2422,34 @@ void PTextEdit::musrView()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]); QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
/** /**
* <p>Callse musrt0 <msr-file>. * <p>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"));
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Calls musrt0 <msr-file>.
*/ */
void PTextEdit::musrT0() void PTextEdit::musrT0()
{ {
@ -2478,10 +2495,10 @@ void PTextEdit::musrT0()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]); QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
@ -2496,7 +2513,7 @@ void PTextEdit::musrFT()
PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find( currentEditor() ), fMusrFTPrevCmd, fAdmin->getHelpUrl("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."); QMessageBox::critical(this, "**ERROR** musrFT", "Couldn't invoke musrFT Options Dialog.");
return; return;
} }
@ -2516,16 +2533,16 @@ void PTextEdit::musrFT()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]); QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
delete dlg; delete dlg;
dlg = 0; dlg = nullptr;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -2536,7 +2553,7 @@ void PTextEdit::musrPrefs()
{ {
PPrefsDialog *dlg = new PPrefsDialog(fAdmin); PPrefsDialog *dlg = new PPrefsDialog(fAdmin);
if (dlg == 0) { if (dlg == nullptr) {
QMessageBox::critical(this, "**ERROR** musrPrefs", "Couldn't invoke Preferences Dialog."); QMessageBox::critical(this, "**ERROR** musrPrefs", "Couldn't invoke Preferences Dialog.");
return; return;
} }
@ -2564,7 +2581,7 @@ void PTextEdit::musrPrefs()
} }
delete dlg; delete dlg;
dlg = 0; dlg = nullptr;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -2605,7 +2622,7 @@ void PTextEdit::musrSetSteps()
QProcess *proc = new QProcess(this); QProcess *proc = new QProcess(this);
if (proc == nullptr) { if (proc == nullptr) {
QMessageBox::critical(0, "**ERROR**", "Couldn't invoke QProcess!"); QMessageBox::critical(nullptr, "**ERROR**", "Couldn't invoke QProcess!");
return; return;
} }
@ -2622,10 +2639,10 @@ void PTextEdit::musrSetSteps()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd[0]); QString msg(tr("Could not execute the output command: ")+cmd[0]);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
@ -2674,42 +2691,42 @@ void PTextEdit::musrSwapMsrMlog()
fileSave(); 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 // swap files
// copy currentFile -> tempFile // copy currentFile -> tempFile
if (QFile::exists(tempFileName)) { if (QFile::exists(tempFileName)) {
if (!QFile::remove(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; return;
} }
} }
if (!QFile::copy(currentFileName, tempFileName)) { 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; return;
} }
// copy swapFile -> currentFile // copy swapFile -> currentFile
if (!QFile::remove(currentFileName)) { 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; return;
} }
if (!QFile::copy(swapFileName, currentFileName)) { 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; return;
} }
// copy tempFile -> swapFile // copy tempFile -> swapFile
if (!QFile::remove(swapFileName)) { 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; return;
} }
if (!QFile::copy(tempFileName, swapFileName)) { 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; return;
} }
// clean up // clean up
if (!QFile::remove(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; return;
} }
@ -2783,10 +2800,10 @@ void PTextEdit::mupp()
if (!proc->waitForStarted()) { if (!proc->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd); QString msg(tr("Could not execute the output command: ")+cmd);
QMessageBox::critical( 0, QMessageBox::critical( nullptr,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
return; return;
} }
} }
@ -2830,7 +2847,7 @@ void PTextEdit::helpAboutQt()
void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus) void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus)
{ {
if (exitStatus == QProcess::CrashExit) { if (exitStatus == QProcess::CrashExit) {
QMessageBox::critical(0, "**FATAL**", "musrWiz returned CrashExit."); QMessageBox::critical(nullptr, "**FATAL**", "musrWiz returned CrashExit.");
return; return;
} }
@ -2843,10 +2860,10 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus)
QString pathName = procEnv.value("HOME", ""); QString pathName = procEnv.value("HOME", "");
pathName += "/.musrfit/musredit/musrWiz.log"; pathName += "/.musrfit/musredit/musrWiz.log";
QString errMsg; QString errMsg;
ifstream fin(pathName.toLatin1().data(), ifstream::in); std::ifstream fin(pathName.toLatin1().data(), std::ifstream::in);
if (!fin.is_open()) { if (!fin.is_open()) {
errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't read %1 file.").arg(pathName); errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't read %1 file.").arg(pathName);
QMessageBox::critical(0, "**ERROR**", errMsg); QMessageBox::critical(nullptr, "**ERROR**", errMsg);
return; return;
} }
char line[128]; char line[128];
@ -2881,7 +2898,7 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus)
QFile logFile(pathName); QFile logFile(pathName);
if (!logFile.remove()) { if (!logFile.remove()) {
errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't delete %1 file.").arg(pathName); errMsg = QString("PTextEdit::exitStatusMusrWiz: couldn't delete %1 file.").arg(pathName);
QMessageBox::critical(0, "**ERROR**", errMsg); QMessageBox::critical(nullptr, "**ERROR**", errMsg);
} }
} }
@ -2894,7 +2911,7 @@ void PTextEdit::exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus)
void PTextEdit::exitStatusMusrSetSteps(int exitCode, QProcess::ExitStatus exitStatus) void PTextEdit::exitStatusMusrSetSteps(int exitCode, QProcess::ExitStatus exitStatus)
{ {
if (exitStatus == QProcess::CrashExit) { if (exitStatus == QProcess::CrashExit) {
QMessageBox::critical(0, "**FATAL**", "musrStep returned CrashExit."); QMessageBox::critical(nullptr, "**FATAL**", "musrStep returned CrashExit.");
return; return;
} }

View File

@ -8,7 +8,7 @@
*****************************************************************************/ *****************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2010-2016 by Andreas Suter * * Copyright (C) 2010-2019 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -39,6 +39,7 @@
#include <QVector> #include <QVector>
#include <QProcess> #include <QProcess>
#include <QFileInfo> #include <QFileInfo>
#include <QByteArray>
#include <QtDebug> #include <QtDebug>
@ -63,7 +64,7 @@ class PTextEdit : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
PTextEdit( QWidget *parent = 0, Qt::WindowFlags f = 0 ); PTextEdit( QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );
virtual ~PTextEdit() {} virtual ~PTextEdit() {}
public slots: public slots:
@ -132,6 +133,7 @@ private slots:
void musrFit(); void musrFit();
void musrMsr2Data(); void musrMsr2Data();
void musrView(); void musrView();
void musrViewFinished(int, QProcess::ExitStatus);
void musrT0(); void musrT0();
void musrFT(); void musrFT();
void musrPrefs(); void musrPrefs();