1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
Author: Tom Jampen <tom@cryptography.ch>
Description:
Fixing a bug that caused texstudio to append a file extension based on the
current selectedFileFilter even if a 'silent save' is performed. This
resulted in data loss in the case a file with the file extension was
already present.
diff -Naurp a/texmaker.cpp b/texmaker.cpp
--- a/texmaker.cpp 2014-12-03 13:27:44.039587135 +0100
+++ b/texmaker.cpp 2014-12-03 13:39:15.605830640 +0100
@@ -2279,18 +2279,21 @@ void Texmaker::fileSaveAs(const QString&
}
// get a file name
- QString fn =fileName;
- if(!saveSilently || fn.isEmpty())
- fn = QFileDialog::getSaveFileName(this,tr("Save As"),currentDir,fileFilters, &selectedFileFilter);
- if (!fn.isEmpty()) {
- static QRegExp fileExt("\\*(\\.[^ )]+)");
- if (fileExt.indexIn(selectedFileFilter) > -1) {
- //add
- int lastsep=qMax(fn.lastIndexOf("/"),fn.lastIndexOf("\\"));
- int lastpoint=fn.lastIndexOf(".");
- if (lastpoint <= lastsep) //if both aren't found or point is in directory name
- fn.append(fileExt.cap(1));
+ QString fn =fileName;
+ if(!saveSilently || fn.isEmpty()) {
+ fn = QFileDialog::getSaveFileName(this,tr("Save As"),currentDir,fileFilters, &selectedFileFilter);
+ if (!fn.isEmpty()) {
+ static QRegExp fileExt("\\*(\\.[^ )]+)");
+ if (fileExt.indexIn(selectedFileFilter) > -1) {
+ //add
+ int lastsep=qMax(fn.lastIndexOf("/"),fn.lastIndexOf("\\"));
+ int lastpoint=fn.lastIndexOf(".");
+ if (lastpoint <= lastsep) //if both aren't found or point is in directory name
+ fn.append(fileExt.cap(1));
+ }
}
+ }
+ if (!fn.isEmpty()) {
if (getEditorViewFromFileName(fn) && getEditorViewFromFileName(fn) != currentEditorView()) {
// trying to save with same name as another already existing file
LatexEditorView *otherEdView = getEditorViewFromFileName(fn);
|