From 3fa68143c245d29d6447d705af1b3af36060c158 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 20 Apr 2015 22:50:59 +0000 Subject: [PATCH] Check that the settings file is writeable git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5255 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 72184cf68..6475dd33a 100644 --- a/main.cpp +++ b/main.cpp @@ -143,7 +143,14 @@ int main(int argc, char *argv[]) { throw std::runtime_error {"Cannot find a usable configuration path \"" + config_path.path ().toStdString () + '"'}; } - QSettings settings(config_path.absoluteFilePath (a.applicationName () + ".ini"), QSettings::IniFormat); + + auto settings_file = config_path.absoluteFilePath (a.applicationName () + ".ini"); + QSettings settings(settings_file, QSettings::IniFormat); + if (!settings.isWritable ()) + { + throw std::runtime_error {QString {"Cannot access \"%1\" for writing"}.arg (settings_file).toStdString ()}; + } + #if WSJT_QDEBUG_TO_FILE // // open a trace file TraceFile trace_file {QDir {QStandardPaths::writableLocation (QStandardPaths::TempLocation)}.absoluteFilePath (a.applicationName () + "_trace.log")};