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

Fixes #33230
  • Loading branch information
suricactus committed Mar 17, 2020
1 parent da60d99 commit c72e003
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 @@ -2815,6 +2815,8 @@ QString QgsProject::homePath() const
if ( !mCachedHomePath.isEmpty() )
return mCachedHomePath;

QFileInfo pfi( fileName() );

if ( !mHomePath.isEmpty() )
{
QFileInfo homeInfo( mHomePath );
Expand All @@ -2824,8 +2826,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 c72e003

Please sign in to comment.