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
This commit is contained in:
Bill Somerville 2014-09-01 15:55:59 +00:00
parent df93758d9b
commit fbf58ae3f3
5 changed files with 13 additions and 9 deletions

View File

@ -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 ());

View File

@ -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 ();

View File

@ -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()));

View File

@ -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},

View File

@ -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: