Fixed config file writing when file does not exist

pull/21/head
Pieter van der Kloet 14 years ago
parent 3e6658428b
commit c9be134226

@ -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…
Cancel
Save