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 | 7d271380868f96a7a2e1f36ee03b97ad9db7c52e (patch) | |
| tree | c382cbcc81cafb4adb7c1cbb1efb2a41c8fe4abe /src/mainwindow.cpp | |
| parent | 19cb2d4076d3515fa490fce7fbd339e92c7c3adf (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 984d8cfd..ae5c1e48 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2166,6 +2166,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) {
@@ -2235,8 +2244,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")
|
