From 82709ea38309bfbdffd70be1695e6617351adc9c Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 18 Oct 2026 17:39:53 +0700 Subject: [PATCH] Add a QGIS patch to speed up project loading with large project files --- vcpkg/ports/qgis/portfile.cmake | 1 + .../qgis/project_load_optimization.patch | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 vcpkg/ports/qgis/project_load_optimization.patch diff --git a/vcpkg/ports/qgis/portfile.cmake b/vcpkg/ports/qgis/portfile.cmake index 05f3e5dd32e..dd1bc2f26f9 100644 --- a/vcpkg/ports/qgis/portfile.cmake +++ b/vcpkg/ports/qgis/portfile.cmake @@ -15,6 +15,7 @@ vcpkg_from_github( processing.patch # Needed to avoid link issue with tinygltf (ATM embedded into QGIS) and _GEOSQueryCallback defined multiple times mesh.patch vector_tiles_dpi_fix.patch + project_load_optimization.patch ) diff --git a/vcpkg/ports/qgis/project_load_optimization.patch b/vcpkg/ports/qgis/project_load_optimization.patch new file mode 100644 index 00000000000..75b80183429 --- /dev/null +++ b/vcpkg/ports/qgis/project_load_optimization.patch @@ -0,0 +1,62 @@ +diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp +index c2220801b7f..8df9e7157a8 100644 +--- a/src/core/project/qgsproject.cpp ++++ b/src/core/project/qgsproject.cpp +@@ -2141,32 +2141,37 @@ bool QgsProject::readProjectFile( const QString &filename, Qgis::ProjectReadFlag + return false; + } + +- QTextStream textStream( &projectFile ); +- QString projectString = textStream.readAll(); +- projectFile.close(); +- +- for ( int i = 0; i < 32; i++ ) ++ if ( !doc->setContent( &projectFile ) ) + { +- if ( i == 9 || i == 10 || i == 13 ) ++ projectFile.seek( 0 ); ++ QTextStream textStream( &projectFile ); ++ QString projectString = textStream.readAll(); ++ projectFile.close(); ++ ++ for ( int i = 0; i < 32; i++ ) + { +- continue; ++ if ( i == 9 || i == 10 || i == 13 ) ++ { ++ continue; ++ } ++ projectString.replace( QChar( i ), u"%1%2%1"_s.arg( FONTMARKER_CHR_FIX, QString::number( i ) ) ); + } +- projectString.replace( QChar( i ), u"%1%2%1"_s.arg( FONTMARKER_CHR_FIX, QString::number( i ) ) ); +- } + +- // location of problem associated with errorMsg +- int line, column; +- QString errorMsg; +- if ( !doc->setContent( projectString, &errorMsg, &line, &column ) ) +- { +- const QString errorString = tr( "Project file read error in file %1: %2 at line %3 column %4" ).arg( projectFile.fileName(), errorMsg ).arg( line ).arg( column ); +- QgsDebugError( errorString ); +- setError( errorString ); ++ int line, column; ++ QString errorMsg; ++ if ( !doc->setContent( projectString, &errorMsg, &line, &column ) ) ++ { ++ const QString errorString = tr( "Project file read error in file %1: %2 at line %3 column %4" ).arg( projectFile.fileName(), errorMsg ).arg( line ).arg( column ); ++ QgsDebugError( errorString ); ++ setError( errorString ); + +- return false; ++ return false; ++ } ++ } ++ else ++ { ++ projectFile.close(); + } +- +- projectFile.close(); + + QgsDebugMsgLevel( "Opened document " + projectFile.fileName(), 2 ); +