mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-07-31 05:02:26 -04:00
Add error checking to jt9 process control by .lock/.quit files
This commit is contained in:
parent
4d9c9e08e2
commit
c58a690bf1
@ -845,8 +845,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create .lock so jt9 will wait
|
pause_jt9 ();
|
||||||
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
|
|
||||||
|
|
||||||
QStringList jt9_args {
|
QStringList jt9_args {
|
||||||
"-s", QApplication::applicationName () // shared memory key,
|
"-s", QApplication::applicationName () // shared memory key,
|
||||||
@ -1040,6 +1039,75 @@ void MainWindow::on_the_minute ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::pause_jt9 ()
|
||||||
|
{
|
||||||
|
// Create .lock so jt9 will wait
|
||||||
|
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
|
||||||
|
if (!l.open(QFile::ReadWrite))
|
||||||
|
{
|
||||||
|
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::release_jt9 ()
|
||||||
|
{
|
||||||
|
// Remove .lock so jt9 will continue
|
||||||
|
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
|
||||||
|
while (l.exists ())
|
||||||
|
{
|
||||||
|
if (!l.remove ())
|
||||||
|
{
|
||||||
|
MessageBox::query_message (this
|
||||||
|
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
|
||||||
|
, tr ("Click OK to retry"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::stop_jt9 ()
|
||||||
|
{
|
||||||
|
// Create .quit so jt9 will exit
|
||||||
|
QFile q {m_config.temp_dir ().absoluteFilePath (".quit")};
|
||||||
|
while (!q.exists ())
|
||||||
|
{
|
||||||
|
if (!q.open (QFile::ReadWrite))
|
||||||
|
{
|
||||||
|
MessageBox::query_message (this
|
||||||
|
, tr ("Error creating \"%1\" - %2").arg (q.fileName ()).arg (q.errorString ())
|
||||||
|
, tr ("Click OK to retry"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
release_jt9 ();
|
||||||
|
if (!proc_jt9.waitForFinished(1000))
|
||||||
|
{
|
||||||
|
proc_jt9.close();
|
||||||
|
}
|
||||||
|
while (q.exists ())
|
||||||
|
{
|
||||||
|
if (!q.remove ())
|
||||||
|
{
|
||||||
|
MessageBox::query_message (this
|
||||||
|
, tr ("Error removing \"%1\" - %2").arg (q.fileName ()).arg (q.errorString ())
|
||||||
|
, tr ("Click OK to retry"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::cleanup_jt9 ()
|
||||||
|
{
|
||||||
|
// Remove .quit as no longer needed
|
||||||
|
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
|
||||||
|
while (l.exists ())
|
||||||
|
{
|
||||||
|
if (!l.remove ())
|
||||||
|
{
|
||||||
|
MessageBox::query_message (this
|
||||||
|
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
|
||||||
|
, tr ("Click OK to retry"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------- MainWindow destructor
|
//--------------------------------------------------- MainWindow destructor
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
@ -2367,12 +2435,7 @@ void MainWindow::closeEvent(QCloseEvent * e)
|
|||||||
int irow=-99;
|
int irow=-99;
|
||||||
plotsave_(&sw,&nw,&nh,&irow);
|
plotsave_(&sw,&nw,&nh,&irow);
|
||||||
mem_jt9->detach();
|
mem_jt9->detach();
|
||||||
QFile quitFile {m_config.temp_dir ().absoluteFilePath (".quit")};
|
stop_jt9 ();
|
||||||
quitFile.open(QIODevice::ReadWrite);
|
|
||||||
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove(); // Allow jt9 to terminate
|
|
||||||
bool b=proc_jt9.waitForFinished(1000);
|
|
||||||
if(!b) proc_jt9.close();
|
|
||||||
quitFile.remove();
|
|
||||||
Q_EMIT finished ();
|
Q_EMIT finished ();
|
||||||
QMainWindow::closeEvent (e);
|
QMainWindow::closeEvent (e);
|
||||||
}
|
}
|
||||||
@ -3020,7 +3083,7 @@ void MainWindow::decode() //decode()
|
|||||||
to_jt9(m_ihsym); //Send m_ihsym to jt9[.exe]
|
to_jt9(m_ihsym); //Send m_ihsym to jt9[.exe]
|
||||||
if(m_ihsym>=m_hsymStop) m_bStart3=true;
|
if(m_ihsym>=m_hsymStop) m_bStart3=true;
|
||||||
}
|
}
|
||||||
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start
|
release_jt9 ();
|
||||||
|
|
||||||
auto now = QDateTime::currentDateTimeUtc();
|
auto now = QDateTime::currentDateTimeUtc();
|
||||||
double tseq = fmod(double(now.toMSecsSinceEpoch() ),1000.0*m_TRperiod)/1000.0;
|
double tseq = fmod(double(now.toMSecsSinceEpoch() ),1000.0*m_TRperiod)/1000.0;
|
||||||
@ -3093,7 +3156,7 @@ void MainWindow::decodeDone ()
|
|||||||
dec_data.params.nagain=0;
|
dec_data.params.nagain=0;
|
||||||
dec_data.params.ndiskdat=0;
|
dec_data.params.ndiskdat=0;
|
||||||
m_nclearave=0;
|
m_nclearave=0;
|
||||||
QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite);
|
pause_jt9 ();
|
||||||
ui->DecodeButton->setChecked (false);
|
ui->DecodeButton->setChecked (false);
|
||||||
decodeBusy(false);
|
decodeBusy(false);
|
||||||
m_RxLog=0;
|
m_RxLog=0;
|
||||||
@ -8118,7 +8181,7 @@ void MainWindow::on_cbMenus_toggled(bool b)
|
|||||||
|
|
||||||
void MainWindow::on_cbCQonly_toggled(bool)
|
void MainWindow::on_cbCQonly_toggled(bool)
|
||||||
{
|
{
|
||||||
QFile {m_config.temp_dir().absoluteFilePath(".lock")}.remove(); // Allow jt9 to start
|
release_jt9 ();
|
||||||
decodeBusy(true);
|
decodeBusy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,6 +770,10 @@ private:
|
|||||||
void writeFoxQSO (QString const& msg);
|
void writeFoxQSO (QString const& msg);
|
||||||
void to_jt9(qint32 n);
|
void to_jt9(qint32 n);
|
||||||
qint32 from_jt9();
|
qint32 from_jt9();
|
||||||
|
void pause_jt9 ();
|
||||||
|
void release_jt9 ();
|
||||||
|
void stop_jt9 ();
|
||||||
|
void cleanup_jt9 ();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int killbyname(const char* progName);
|
extern int killbyname(const char* progName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user