Strip the default suffix if saving to git branch

For some reason the file selection dialog box now always adds a default
suffix to the file name we pick - which results in our test for git
storage to fail.

So if the filename looks like "<path>[branch].ssrf" then remove the suffix
that was added.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-05-27 11:14:26 -07:00
parent 17b7bdfd2e
commit a8c013869b

View file

@ -1277,6 +1277,7 @@ int MainWindow::file_save_as(void)
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
selection_dialog.setAcceptMode(QFileDialog::AcceptSave);
selection_dialog.setFileMode(QFileDialog::AnyFile);
selection_dialog.setDefaultSuffix("");
/* if the exit/cancel button is pressed return */
if (!selection_dialog.exec())
@ -1284,6 +1285,13 @@ int MainWindow::file_save_as(void)
/* get the first selected file */
filename = selection_dialog.selectedFiles().at(0);
/* now for reasons I don't understand we appear to add a .ssrf to
* git style filenames <path>/directory[branch]
* so let's remove that */
QRegExp r("\\[.*\\]\\.ssrf$", Qt::CaseInsensitive);
if (filename.contains(r))
filename.remove(QRegExp("\\.ssrf$", Qt::CaseInsensitive));
if (filename.isNull() || filename.isEmpty())
return report_error("No filename to save into");