Skip to content

Commit

Permalink
Merge pull request #373 from openstudiocoalition/372_Warn_Settings_no…
Browse files Browse the repository at this point in the history
…t_Writable

Fix #372 - writeSettings / writeLibraryPaths warn user if settings can't be written to
  • Loading branch information
macumber authored Jun 7, 2021
2 parents 7591ef7 + e6b70fd commit e4ab048
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/openstudio_app/OpenStudioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
#include <QTcpServer>
#include <QtConcurrent>
#include <QtGlobal>
#include <QSettings>

#include <openstudio/OpenStudio.hxx>
#include <openstudio/utilities/idd/IddEnums.hxx>
Expand Down Expand Up @@ -1173,6 +1174,10 @@ void OpenStudioApp::writeSettings() {
QString organizationName = QCoreApplication::organizationName();
QString applicationName = QCoreApplication::applicationName();
QSettings settings(organizationName, applicationName);
if (!settings.isWritable()) {
QMessageBox::warning(nullptr, tr("Settings file not writable"),
tr("Your settings file '") + settings.fileName() + tr("' is not writable. Adjust the file permissions"));
}
settings.setValue("lastPath", lastPath());
}

Expand Down Expand Up @@ -1302,6 +1307,11 @@ void OpenStudioApp::writeLibraryPaths(std::vector<openstudio::path> paths) {

QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());

if (!settings.isWritable()) {
QMessageBox::warning(nullptr, tr("Settings file not writable"),
tr("Your settings file '") + settings.fileName() + tr("' is not writable. Adjust the file permissions"));
}

if (paths == defaultPaths) {
settings.remove("library");
} else {
Expand Down

0 comments on commit e4ab048

Please sign in to comment.