Skip to content
Permalink
Browse files

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

…owser panel

Fixes #33230
  • Loading branch information
suricactus committed Mar 17, 2020
1 parent da60d99 commit c72e003aab76365929550cc45efa63b0a2ed5836
Showing with 15 additions and 1 deletion.
  1. +8 −1 src/core/qgsproject.cpp
  2. +7 −0 tests/src/python/test_qgsproject.py
@@ -2815,6 +2815,8 @@ QString QgsProject::homePath() const
if ( !mCachedHomePath.isEmpty() )
return mCachedHomePath;

QFileInfo pfi( fileName() );

if ( !mHomePath.isEmpty() )
{
QFileInfo homeInfo( mHomePath );
@@ -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;
@@ -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 c72e003

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