Skip to content

Commit e4cd552

Browse files
committed
parse embedded project only once (speedups loading of multiple embedded layers from the same project)
1 parent b5f6d2c commit e4cd552

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/core/qgsproject.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,16 +1689,27 @@ QString QgsProject::layerIsEmbedded( const QString& id ) const
16891689
bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& projectFilePath, QList<QDomNode>& brokenNodes,
16901690
QList< QPair< QgsVectorLayer*, QDomElement > >& vectorLayerList, bool saveFlag )
16911691
{
1692-
QFile projectFile( projectFilePath );
1693-
if ( !projectFile.open( QIODevice::ReadOnly ) )
1694-
{
1695-
return false;
1696-
}
1692+
QgsDebugCall;
16971693

1698-
QDomDocument projectDocument;
1699-
if ( !projectDocument.setContent( &projectFile ) )
1694+
static QString prevProjectFilePath;
1695+
static QDomDocument projectDocument;
1696+
1697+
if ( projectFilePath != prevProjectFilePath )
17001698
{
1701-
return false;
1699+
prevProjectFilePath.clear();
1700+
1701+
QFile projectFile( projectFilePath );
1702+
if ( !projectFile.open( QIODevice::ReadOnly ) )
1703+
{
1704+
return false;
1705+
}
1706+
1707+
if ( !projectDocument.setContent( &projectFile ) )
1708+
{
1709+
return false;
1710+
}
1711+
1712+
prevProjectFilePath = projectFilePath;
17021713
}
17031714

17041715
//does project store pathes absolute or relative?

0 commit comments

Comments
 (0)