From aec3834739c1bd13e087e80b656ea158caae53d0 Mon Sep 17 00:00:00 2001
From: Bill Somerville <g4wjs@classdesign.com>
Date: Sun, 29 Sep 2013 21:23:06 +0000
Subject: [PATCH] Fix decode button getting stuck on first decode cycle.

The ".quit" file that is used to communicate shutdown to the "jt9"
sub-process was not getting deleted under some obscure
circumstances. If "wsjtx" is started with the ".quit" file in place;
"jt9" starts and stops immediately rather than going into it's normal
wait state. Probably some sort of race condition between the two
processes dying and file and/or shared memory locks.

Rather than track the issue down I have added code to ensure that
".quit" is removed before starting "jt9".



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3586 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
---
 mainwindow.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8b34676ca..307c3e9c4 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -326,10 +326,23 @@ MainWindow::MainWindow(QSettings * settings, QSharedMemory *shdmem, QString *the
   ui->bandComboBox->addItems(m_bandDescription);
   ui->bandComboBox->setCurrentIndex(m_band);
 
+  {
+    //delete any .quit file that might have been left lying around
+    //since its presence will cause jt9 to exit a soon as we start it
+    //and decodes will hang
+    QString quitFileName (m_appDir + "/.quit");
+    QFile quitFile (quitFileName);
+    while (quitFile.exists ())
+      {
+	if (!quitFile.remove ())
+	  {
+	    msgBox ("Error removing " + quitFileName + " - OK to retry.");
+	  }
+      }
+  }
+
   QFile lockFile(m_appDir + "/.lock");     //Create .lock so jt9 will wait
   lockFile.open(QIODevice::ReadWrite);
-  //QFile quitFile(m_appDir + "/.lock");
-  //quitFile.remove();
 
 // Multiple instances: make the Qstring key into command line arg
 // Multiple instances: start "jt9 -s <thekey>"