Skip to content
Permalink
Browse files

When a new project is saved, "Project Home" does not appear in the br…

…owser panel
  • Loading branch information
github-actions authored and nyalldawson committed Mar 17, 2020
1 parent dcf86b3 commit ee5e99b6998a2fc65fd7f6729bf070a34c699ead
Showing with 15 additions and 1 deletion.
  1. +8 −1 src/core/qgsproject.cpp
  2. +7 −0 tests/src/python/test_qgsproject.py
@@ -2745,6 +2745,8 @@ QString QgsProject::homePath() const
if ( !mCachedHomePath.isEmpty() )
return mCachedHomePath;

QFileInfo pfi( fileName() );

if ( !mHomePath.isEmpty() )
{
QFileInfo homeInfo( mHomePath );
@@ -2754,8 +2756,13 @@ QString QgsProject::homePath() const
return mHomePath;
}
}
else if ( !fileName().isEmpty() )
{
mCachedHomePath = pfi.path();

return mCachedHomePath;
}

QFileInfo pfi( fileName() );
if ( !pfi.exists() )
{
mCachedHomePath = mHomePath;
@@ -1018,6 +1018,13 @@ def testHomePath(self):
scope = QgsExpressionContextUtils.projectScope(p)
self.assertEqual(scope.variable('project_home'), '../home')

p = QgsProject()
path_changed_spy = QSignalSpy(p.homePathChanged)
p.setFileName('/tmp/not/existing/here/path.qgz')
self.assertFalse(p.presetHomePath())
self.assertEqual(p.homePath(), '/tmp/not/existing/here')
self.assertEqual(len(path_changed_spy), 1)

def testDirtyBlocker(self):
# first test manual QgsProjectDirtyBlocker construction
p = QgsProject()

0 comments on commit ee5e99b

Please sign in to comment.
You can’t perform that action at this time.