From 4b6b26c5533b5fba516b3710be34582caef727a9 Mon Sep 17 00:00:00 2001 From: dubslow Date: Tue, 11 Nov 2014 16:06:15 -0600 Subject: [PATCH] more robust exporting, fixes #716 --- src/widget/form/settings/identityform.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widget/form/settings/identityform.cpp b/src/widget/form/settings/identityform.cpp index b6bf1439e..fa8c32082 100644 --- a/src/widget/form/settings/identityform.cpp +++ b/src/widget/form/settings/identityform.cpp @@ -167,7 +167,24 @@ void IdentityForm::onExportClicked() QDir::home().filePath(current), tr("Tox save file (*.tox)", "save dialog filter")); if (!path.isEmpty()) - QFile::copy(QDir(Settings::getSettingsDirPath()).filePath(current), path); + { + bool success; + if (QFile::exists(path)) + { + // should we popup a warning? + // if (!checkContinue(tr("Overwriting a file"), tr("Are you sure you want to overwrite %1?").arg(path))) + // return; + success = QFile::remove(path); + if (!success) + { + QMessageBox::warning(this, tr("Failed to remove file"), tr("The file you chose to overwrite could not be removed first.")); + return; + } + } + success = QFile::copy(QDir(Settings::getSettingsDirPath()).filePath(current), path); + if (!success) + QMessageBox::warning(this, tr("Failed to copy file"), tr("The file you chose could not be written to.")); + } } void IdentityForm::onDeleteClicked()