diff options
| author | Tannin <devnull@localhost> | 2014-09-10 20:43:33 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-09-10 20:43:33 +0200 |
| commit | 430048d201a39a8371381e6a0921d71fc6e7011b (patch) | |
| tree | 138a4ca2ac5c6c268e406e29d1e6d361cc6a5866 /src/mainwindow.cpp | |
| parent | 4c42a6fbf1b80b76371f9f99f2655980fded5d0c (diff) | |
when MO fails to overwrite its ini file it tries another method using qt functions
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 954c6e85..602f3033 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2133,6 +2133,15 @@ void MainWindow::readSettings() }
+bool renameFile(const QString &oldName, const QString &newName, bool overwrite = true)
+{
+ if (overwrite && QFile::exists(newName)) {
+ QFile::remove(newName);
+ }
+ return QFile::rename(oldName, newName);
+}
+
+
void MainWindow::storeSettings()
{
if (m_CurrentProfile == NULL) {
@@ -2202,8 +2211,12 @@ void MainWindow::storeSettings() }
if (result == QSettings::NoError) {
if (!shellRename(iniFile + ".new", iniFile, true, this)) {
- QMessageBox::critical(this, tr("Failed to write settings"),
- tr("An error occured trying to write back MO settings: %1").arg(windowsErrorString(::GetLastError())));
+ DWORD err = ::GetLastError();
+ // make a second attempt using qt functions but if that fails print the error from the first attempt
+ if (!renameFile(iniFile + ".new", iniFile)) {
+ QMessageBox::critical(this, tr("Failed to write settings"),
+ tr("An error occured trying to write back MO settings: %1").arg(windowsErrorString(err)));
+ }
}
} else {
QString reason = result == QSettings::AccessError ? tr("File is write protected")
|
