Skip to content

Commit c4b9106

Browse files
authoredJul 9, 2018
Merge pull request #7380 from slarosa/fix_18485
Fixes #18485 - do not truncate project title if filename contains period
2 parents e065df1 + 7ece90c commit c4b9106

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎src/core/qgsproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ QString QgsProject::baseName() const
508508
}
509509
else
510510
{
511-
return QFileInfo( mFile.fileName() ).baseName();
511+
return QFileInfo( mFile.fileName() ).completeBaseName();
512512
}
513513
}
514514

‎tests/src/python/test_qgsproject.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,20 @@ def testLayerChangeDirtiesProject(self):
10911091
self.assertTrue(l.setSubsetString('class=\'a\''))
10921092
self.assertTrue(p.isDirty())
10931093

1094+
def testProjectTitleWithPeriod(self):
1095+
tmpDir = QTemporaryDir()
1096+
tmpFile = "{}/2.18.21.qgs".format(tmpDir.path())
1097+
tmpFile2 = "{}/qgis-3.2.0.qgs".format(tmpDir.path())
1098+
1099+
p0 = QgsProject()
1100+
p0.setFileName(tmpFile)
1101+
1102+
p1 = QgsProject()
1103+
p1.setFileName(tmpFile2)
1104+
1105+
self.assertEqual(p0.baseName(), '2.18.21')
1106+
self.assertEqual(p1.baseName(), 'qgis-3.2.0')
1107+
10941108

10951109
if __name__ == '__main__':
10961110
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.