diff --git a/lib/jt9a.f90 b/lib/jt9a.f90 index 3ca567b81..f316a8226 100644 --- a/lib/jt9a.f90 +++ b/lib/jt9a.f90 @@ -18,12 +18,11 @@ subroutine jt9a() integer*1 attach_jt9 ! integer*1 lock_jt9,unlock_jt9 integer size_jt9 - integer itime(8) ! Multiple instances: character*80 mykey + integer :: lun, stat type(dec_data), pointer :: shared_data type(params_block) :: local_params - logical fileExists volatile shared_data ! Multiple instances: @@ -39,17 +38,19 @@ subroutine jt9a() i0 = len(mykey) i0=setkey_jt9(trim(mykey)) i1=attach_jt9() - msdelay=1 + msdelay=100 -! Wait here until the .lock file is removed by GUI -10 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists) - if(fileExists) then +! Wait here until the .start file is created by GUI +10 open(newunit=lun,file=trim(temp_dir)//'/.start',iostat=stat,status='old') + if(stat.ne.0) then call sleep_msec(msdelay) go to 10 endif + close(unit=lun,status='delete') - inquire(file=trim(temp_dir)//'/.quit',exist=fileExists) - if(fileExists) then + open(newunit=lun,file=trim(temp_dir)//'/.quit',iostat=stat,status='old') + if(stat.eq.0) then + close(unit=lun,status='delete') i1=detach_jt9() go to 999 endif @@ -83,9 +84,12 @@ subroutine jt9a() call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000) call timer('decoder ',1) -! Wait here until GUI routine decodeDone() has re-created the .lock file -100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists) - if(fileExists) go to 10 +! Wait here until GUI routine decodeDone() has re-created the .start file +100 open(newunit=lun,file=trim(temp_dir)//'/.stop',iostat=stat,status='old') + if(stat.eq.0) then + close(unit=lun,status='delete') + go to 10 + endif call sleep_msec(msdelay) go to 100 diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 8c3905d98..8622a5213 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -1041,8 +1041,8 @@ void MainWindow::on_the_minute () void MainWindow::pause_jt9 () { - // Create .lock so jt9 will wait - QFile l {m_config.temp_dir ().absoluteFilePath (".lock")}; + // Create .stop so jt9 will wait + QFile l {m_config.temp_dir ().absoluteFilePath (".stop")}; if (!l.open(QFile::ReadWrite)) { MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())); @@ -1051,21 +1051,11 @@ void MainWindow::pause_jt9 () void MainWindow::release_jt9 () { - // Remove .lock so jt9 will continue - QFile l {m_config.temp_dir ().absoluteFilePath (".lock")}; - while (l.exists ()) + // Create .start so jt9 will continue + QFile l {m_config.temp_dir ().absoluteFilePath (".start")}; + if (!l.open(QFile::ReadWrite)) { - if (!l.remove ()) - { - if (MessageBox::Cancel == MessageBox::query_message (this - , tr ("IPC Error") - , tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()) - , QString {} - , MessageBox::Retry | MessageBox::Cancel)) - { - break; - } - } + MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())); } } @@ -1108,21 +1098,6 @@ void MainWindow::stop_jt9 () } } -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::~MainWindow() { diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index 675e25a4a..c1f99df74 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -774,7 +774,6 @@ private: void pause_jt9 (); void release_jt9 (); void stop_jt9 (); - void cleanup_jt9 (); }; extern int killbyname(const char* progName);