Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #7381 from slarosa/backport_fix_18485
[BACKPORT] Fixes #18485 - do not truncate project title if filename contains period
  • Loading branch information
slarosa committed Jul 9, 2018
2 parents 4f4c928 + d064086 commit 9e63678
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -508,7 +508,7 @@ QString QgsProject::baseName() const
}
else
{
return QFileInfo( mFile.fileName() ).baseName();
return QFileInfo( mFile.fileName() ).completeBaseName();
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/src/python/test_qgsproject.py
Expand Up @@ -1091,6 +1091,20 @@ def testLayerChangeDirtiesProject(self):
self.assertTrue(l.setSubsetString('class=\'a\''))
self.assertTrue(p.isDirty())

def testProjectTitleWithPeriod(self):
tmpDir = QTemporaryDir()
tmpFile = "{}/2.18.21.qgs".format(tmpDir.path())
tmpFile2 = "{}/qgis-3.2.0.qgs".format(tmpDir.path())

p0 = QgsProject()
p0.setFileName(tmpFile)

p1 = QgsProject()
p1.setFileName(tmpFile2)

self.assertEqual(p0.baseName(), '2.18.21')
self.assertEqual(p1.baseName(), 'qgis-3.2.0')


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

0 comments on commit 9e63678

Please sign in to comment.