Skip to content

Commit

Permalink
Patch QGIS Qt6 overlay to fix project load containing bad characters
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Oct 24, 2023
1 parent f44eea4 commit 37800eb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions vcpkg/overlay/qgis-qt6/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vcpkg_from_github(
bigobj.patch
poly2tri.patch
mesh.patch
project_load.patch
vectortilelabels.patch # Remove when updating to QGIS 3.34
version.patch # Remove when updating to QGIS 3.34
snapping_properties.patch # Remove when updating to QGIS 3.34
Expand Down
41 changes: 41 additions & 0 deletions vcpkg/overlay/qgis-qt6/project_load.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp
index 583c093c0ba..af332bf3036 100644
--- a/src/core/project/qgsproject.cpp
+++ b/src/core/project/qgsproject.cpp
@@ -1831,19 +1831,30 @@ bool QgsProject::readProjectFile( const QString &filename, Qgis::ProjectReadFlag
return false;
}

+ QTextStream textStream( &projectFile );
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ textStream.setCodec( "UTF-8" );
+#endif
+ QString projectString = textStream.readAll();
+ projectFile.close();
+
+ for ( int i = 0; i < 32; i++ )
+ {
+ if ( i == 9 || i == 10 || i == 13 )
+ {
+ continue;
+ }
+ projectString.remove( QChar( i ) );
+ }
+
// location of problem associated with errorMsg
int line, column;
QString errorMsg;
-
- if ( !doc->setContent( &projectFile, &errorMsg, &line, &column ) )
+ 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 );
-
- projectFile.close();
-
setError( errorString );

return false;

0 comments on commit 37800eb

Please sign in to comment.