mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 16:06:44 +00:00
Fixed config file writing when file does not exist
This commit is contained in:
parent
3e6658428b
commit
c9be134226
1 changed files with 6 additions and 5 deletions
|
@ -335,17 +335,17 @@ void MainDialog::writeConfig()
|
||||||
QFile file(QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
|
QFile file(QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
|
||||||
"openmw", "openmw.cfg")));
|
"openmw", "openmw.cfg")));
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||||
// File cannot be opened or created
|
// File cannot be opened or created
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle("Error opening OpenMW configuration file");
|
msgBox.setWindowTitle("Error writing OpenMW configuration file");
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setText(tr("<br><b>Could not open %0</b><br><br> \
|
msgBox.setText(tr("<br><b>Could not open or create %0</b><br><br> \
|
||||||
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|
||||||
return;
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
|
@ -371,10 +371,11 @@ void MainDialog::writeConfig()
|
||||||
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|
||||||
return;
|
std::exit(1);;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.write(buffer);
|
file.write(buffer);
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
|
|
||||||
// Write the list of game files to the config
|
// Write the list of game files to the config
|
||||||
|
|
Loading…
Reference in a new issue