Skip to content

Commit

Permalink
When a new project is saved, "Project Home" does not appear in the br…
Browse files Browse the repository at this point in the history
…owser panel
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Mar 17, 2020
1 parent dcf86b3 commit ee5e99b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/qgsproject.cpp
Expand Up @@ -2745,6 +2745,8 @@ QString QgsProject::homePath() const
if ( !mCachedHomePath.isEmpty() )
return mCachedHomePath;

QFileInfo pfi( fileName() );

if ( !mHomePath.isEmpty() )
{
QFileInfo homeInfo( mHomePath );
Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions tests/src/python/test_qgsproject.py
Expand Up @@ -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()
Expand Down

0 comments on commit ee5e99b

Please sign in to comment.