Fix config export (#220)

If the user presses the Cancel button using the QFileDialog::getSaveFileName() modal file dialog, it will return null string.

Adding this condition will prevent to show an error when trying to write to disk using an invalid filename.
This commit is contained in:
Alfredo Ramos
2018-05-13 16:46:17 -05:00
committed by Dharkael
parent 45efe136da
commit e69859dc72

View File

@@ -100,6 +100,12 @@ void GeneneralConf::importConfiguration() {
void GeneneralConf::exportFileConfiguration() {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
"flameshot.conf");
// Cancel button
if (fileName.isNull()) {
return;
}
QFile targetFile(fileName);
if (targetFile.exists()) {
targetFile.remove();