From d4e69f0b2315053f181bacdadb373f900162cdf8 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 1 Sep 2014 15:55:59 +0000 Subject: [PATCH] Make temp directory unique in test mode. The Qt test mode that uses special paths for writeable files (via QtStandardPaths) doesn't make a special temporary file path. This change appends " - test_mode" to the WSJT-X unique temporary file path so that an application run in test mode will not interact with another running in normal mode. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4240 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 12 ++++++++---- Configuration.hpp | 2 +- main.cpp | 2 +- mainwindow.cpp | 4 ++-- mainwindow.h | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index ae4ee968d..7d76a7308 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -207,7 +207,7 @@ class Configuration::impl final public: using FrequencyDelta = Radio::FrequencyDelta; - explicit impl (Configuration * self, QString const& instance_key, QSettings * settings, QWidget * parent); + explicit impl (Configuration * self, QString const& instance_key, QSettings * settings, bool test_mode, QWidget * parent); ~impl (); bool have_rig (bool open_if_closed = true); @@ -398,8 +398,8 @@ private: // delegate to implementation class -Configuration::Configuration (QString const& instance_key, QSettings * settings, QWidget * parent) - : m_ {this, instance_key, settings, parent} +Configuration::Configuration (QString const& instance_key, QSettings * settings, bool test_mode, QWidget * parent) + : m_ {this, instance_key, settings, test_mode, parent} { } @@ -517,7 +517,7 @@ void Configuration::sync_transceiver (bool force_signal, bool enforce_mode_and_s } -Configuration::impl::impl (Configuration * self, QString const& instance_key, QSettings * settings, QWidget * parent) +Configuration::impl::impl (Configuration * self, QString const& instance_key, QSettings * settings, bool test_mode, QWidget * parent) : QDialog {parent} , self_ {self} , ui_ {new Ui::configuration_dialog} @@ -576,6 +576,10 @@ Configuration::impl::impl (Configuration * self, QString const& instance_key, QS } QString unique_directory {instance_key}; + if (test_mode) + { + unique_directory += " - test_mode"; + } if (!temp_path_.mkpath (unique_directory) || !temp_path_.cd (unique_directory)) { QMessageBox::critical (this, "WSJT-X", tr ("Create temporary directory error: ") + temp_path_.absolutePath ()); diff --git a/Configuration.hpp b/Configuration.hpp index caff847d8..ff0c9a75b 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -61,7 +61,7 @@ public: enum DataMode {data_mode_none, data_mode_USB, data_mode_data}; - explicit Configuration (QString const& instance_key, QSettings * settings, QWidget * parent = nullptr); + explicit Configuration (QString const& instance_key, QSettings * settings, bool test_mode, QWidget * parent = nullptr); ~Configuration (); int exec (); diff --git a/main.cpp b/main.cpp index 35135525f..dcbb12260 100644 --- a/main.cpp +++ b/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) ).toBool () ? 1u : 4u; } - MainWindow w(multiple, &settings, &mem_jt9, my_key, downSampleFactor); + MainWindow w(multiple, &settings, &mem_jt9, my_key, downSampleFactor, parser.isSet (test_option)); w.show(); QObject::connect (&a, SIGNAL (lastWindowClosed()), &a, SLOT (quit())); diff --git a/mainwindow.cpp b/mainwindow.cpp index a2aae7de3..1c51128a1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -67,13 +67,13 @@ private: //--------------------------------------------------- MainWindow constructor MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdmem, QString const& thekey, - unsigned downSampleFactor, QWidget *parent) : + unsigned downSampleFactor, bool test_mode, QWidget *parent) : QMainWindow(parent), m_revision {revision ("$Rev$")}, m_multiple {multiple}, m_settings (settings), ui(new Ui::MainWindow), - m_config (thekey, settings, this), + m_config (thekey, settings, test_mode, this), m_wideGraph (new WideGraph (settings)), m_logDlg (new LogQSO (program_title (), settings, &m_config, this)), m_dialFreq {0}, diff --git a/mainwindow.h b/mainwindow.h index 16c1402e5..78da98615 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -58,7 +58,7 @@ public: // Multiple instances: call MainWindow() with *thekey explicit MainWindow(bool multiple, QSettings *, QSharedMemory *shdmem, QString const& thekey, - unsigned downSampleFactor, QWidget *parent = 0); + unsigned downSampleFactor, bool test_mode, QWidget *parent = 0); ~MainWindow(); public slots: