mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-29 07:39:43 -05:00
Report failed sub-process exit statuses then exit gracefully
This commit is contained in:
parent
1d6835b859
commit
98d4f771c2
@ -1,6 +1,7 @@
|
|||||||
//------------------------------------------------------------------ MainWindow
|
//------------------------------------------------------------------ MainWindow
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "revision_utils.hpp"
|
#include "revision_utils.hpp"
|
||||||
|
#include "widgets/MessageBox.hpp"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "devsetup.h"
|
#include "devsetup.h"
|
||||||
#include "plotter.h"
|
#include "plotter.h"
|
||||||
@ -101,14 +102,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
SLOT(showStatusMessage(QString)));
|
SLOT(showStatusMessage(QString)));
|
||||||
createStatusBar();
|
createStatusBar();
|
||||||
|
|
||||||
connect(&proc_m65, SIGNAL(readyReadStandardOutput()),
|
connect(&proc_m65, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
|
||||||
this, SLOT(readFromStdout()));
|
connect(&proc_m65, &QProcess::errorOccurred, this, &MainWindow::m65_error);
|
||||||
|
connect(&proc_m65, static_cast<void (QProcess::*) (int, QProcess::ExitStatus)> (&QProcess::finished),
|
||||||
connect(&proc_m65, SIGNAL(error(QProcess::ProcessError)),
|
[this] (int exitCode, QProcess::ExitStatus status) {
|
||||||
this, SLOT(m65_error()));
|
if (subProcessFailed (&proc_m65, exitCode, status))
|
||||||
|
{
|
||||||
connect(&proc_m65, SIGNAL(readyReadStandardError()),
|
QTimer::singleShot (0, this, SLOT (close ()));
|
||||||
this, SLOT(readFromStderr()));
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connect(&proc_editor, SIGNAL(error(QProcess::ProcessError)),
|
connect(&proc_editor, SIGNAL(error(QProcess::ProcessError)),
|
||||||
this, SLOT(editor_error()));
|
this, SLOT(editor_error()));
|
||||||
@ -1341,11 +1343,33 @@ void MainWindow::decode() //decode()
|
|||||||
decodeBusy(true);
|
decodeBusy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::m65_error() //m65_error
|
bool MainWindow::subProcessFailed (QProcess * process, int exit_code, QProcess::ExitStatus status)
|
||||||
|
{
|
||||||
|
if (exit_code || QProcess::NormalExit != status)
|
||||||
|
{
|
||||||
|
QStringList arguments;
|
||||||
|
for (auto argument: process->arguments ())
|
||||||
|
{
|
||||||
|
if (argument.contains (' ')) argument = '"' + argument + '"';
|
||||||
|
arguments << argument;
|
||||||
|
}
|
||||||
|
MessageBox::critical_message (this, tr ("Subprocess Error")
|
||||||
|
, tr ("Subprocess failed with exit code %1")
|
||||||
|
.arg (exit_code)
|
||||||
|
, tr ("Running: %1\n%2")
|
||||||
|
.arg (process->program () + ' ' + arguments.join (' '))
|
||||||
|
.arg (QString {process->readAllStandardError()}));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::m65_error (QProcess::ProcessError)
|
||||||
{
|
{
|
||||||
if(!m_killAll) {
|
if(!m_killAll) {
|
||||||
msgBox("Error starting or running\n" + m_appDir + "/m65 -s");
|
msgBox("Error starting or running\n" + m_appDir + "/m65 -s\n\n"
|
||||||
exit(1);
|
+ proc_m65.errorString ());
|
||||||
|
QTimer::singleShot (0, this, SLOT (close ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1356,12 +1380,6 @@ void MainWindow::editor_error() //editor_error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::readFromStderr() //readFromStderr
|
|
||||||
{
|
|
||||||
QByteArray t=proc_m65.readAllStandardError();
|
|
||||||
msgBox(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::readFromStdout() //readFromStdout
|
void MainWindow::readFromStdout() //readFromStdout
|
||||||
{
|
{
|
||||||
while(proc_m65.canReadLine())
|
while(proc_m65.canReadLine())
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QProcess>
|
||||||
#include "getfile.h"
|
#include "getfile.h"
|
||||||
#include "soundin.h"
|
#include "soundin.h"
|
||||||
#include "soundout.h"
|
#include "soundout.h"
|
||||||
@ -39,8 +40,7 @@ public slots:
|
|||||||
void diskWriteFinished();
|
void diskWriteFinished();
|
||||||
void freezeDecode(int n);
|
void freezeDecode(int n);
|
||||||
void readFromStdout();
|
void readFromStdout();
|
||||||
void readFromStderr();
|
void m65_error (QProcess::ProcessError);
|
||||||
void m65_error();
|
|
||||||
void editor_error();
|
void editor_error();
|
||||||
void guiUpdate();
|
void guiUpdate();
|
||||||
void doubleClickOnCall(QString hiscall, bool ctrl);
|
void doubleClickOnCall(QString hiscall, bool ctrl);
|
||||||
@ -277,6 +277,7 @@ private:
|
|||||||
void ba2msg(QByteArray ba, char* message);
|
void ba2msg(QByteArray ba, char* message);
|
||||||
void msgtype(QString t, QLineEdit* tx);
|
void msgtype(QString t, QLineEdit* tx);
|
||||||
void stub();
|
void stub();
|
||||||
|
bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void getfile(QString fname, bool xpol, int idInt);
|
extern void getfile(QString fname, bool xpol, int idInt);
|
||||||
|
Loading…
Reference in New Issue
Block a user