From a16c9be50a5300e091b63b328a912d4cc5b6f2ce Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:38:07 +0100 Subject: [PATCH 01/27] [OGR provider] Fix inappropriate use of OGREnvelope3D --- src/core/providers/ogr/qgsogrprovider.cpp | 28 ++++++++++++++++--- src/core/providers/ogr/qgsogrprovider.h | 3 +- .../providers/ogr/qgsogrproviderutils.cpp | 9 +++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/core/providers/ogr/qgsogrprovider.cpp b/src/core/providers/ogr/qgsogrprovider.cpp index 9f8e410f12f6..29ade0172fa1 100644 --- a/src/core/providers/ogr/qgsogrprovider.cpp +++ b/src/core/providers/ogr/qgsogrprovider.cpp @@ -1234,7 +1234,7 @@ QgsRectangle QgsOgrProvider::extent() const QgsCPLHTTPFetchOverrider oCPLHTTPFetcher( mAuthCfg ); QgsSetCPLHTTPFetchOverriderInitiatorClass( oCPLHTTPFetcher, QStringLiteral( "QgsOgrProvider" ) ); - mExtent2D.reset( new OGREnvelope3D() ); + mExtent2D.reset( new OGREnvelope() ); // get the extent_ (envelope) of the layer QgsDebugMsgLevel( QStringLiteral( "Starting computing extent. subset: '%1'" ).arg( mSubsetString ), 3 ); @@ -1283,8 +1283,16 @@ QgsRectangle QgsOgrProvider::extent() const else { QgsDebugMsgLevel( QStringLiteral( "will apply slow default 2D extent computing" ), 3 ); - OGRErr err = mOgrLayer->computeExtent3DSlowly( mExtent2D.get() ); - if ( err != OGRERR_NONE ) + OGREnvelope3D sExtent3D; + OGRErr err = mOgrLayer->computeExtent3DSlowly( &sExtent3D ); + if ( err == OGRERR_NONE ) + { + mExtent2D->MinX = sExtent3D.MinX; + mExtent2D->MinY = sExtent3D.MinY; + mExtent2D->MaxX = sExtent3D.MaxX; + mExtent2D->MaxY = sExtent3D.MaxY; + } + else { QgsDebugMsgLevel( QStringLiteral( "Failure: unable to compute slow extent2D (ogr error: %1)" ).arg( err ), 1 ); mExtent2D.reset(); @@ -1355,7 +1363,16 @@ QgsBox3D QgsOgrProvider::extent3D() const mOgrOrigLayer->ExecuteSQLNoReturn( sql ); } else - mOgrLayer->GetExtent( mExtent3D.get(), true ); // switch OLCFastGetExtent flag to TRUE + { + OGREnvelope envelope2D; + if ( mOgrLayer->GetExtent( &envelope2D, true ) == OGRERR_NONE ) // switch OLCFastGetExtent flag to TRUE + { + mExtent3D->MinX = envelope2D.MinX; + mExtent3D->MinY = envelope2D.MinY; + mExtent3D->MaxX = envelope2D.MaxX; + mExtent3D->MaxY = envelope2D.MaxY; + } + } if ( !mOgrLayer->TestCapability( OLCFastGetExtent ) ) { @@ -4720,4 +4737,7 @@ QString QgsOgrProvider::fileVectorFilters() const return QgsOgrProviderUtils::fileVectorFilters(); } +#undef TEXT_PROVIDER_KEY +#undef TEXT_PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/ogr/qgsogrprovider.h b/src/core/providers/ogr/qgsogrprovider.h index f7fb5e052ccf..0e26bb6019ab 100644 --- a/src/core/providers/ogr/qgsogrprovider.h +++ b/src/core/providers/ogr/qgsogrprovider.h @@ -21,6 +21,7 @@ email : sherman at mrcc.com #include "qgsvectordataprovider.h" #include "qgsogrproviderutils.h" +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include class QgsOgrLayer; @@ -216,7 +217,7 @@ class QgsOgrProvider final: public QgsVectorDataProvider QMap mDefaultValues; bool mFirstFieldIsFid = false; - mutable std::unique_ptr< OGREnvelope3D > mExtent2D; + mutable std::unique_ptr< OGREnvelope > mExtent2D; mutable std::unique_ptr< OGREnvelope3D > mExtent3D; bool mForceRecomputeExtent = false; diff --git a/src/core/providers/ogr/qgsogrproviderutils.cpp b/src/core/providers/ogr/qgsogrproviderutils.cpp index 93a80b402b57..9c1b80eb3457 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.cpp +++ b/src/core/providers/ogr/qgsogrproviderutils.cpp @@ -3225,9 +3225,16 @@ OGRErr QgsOgrLayer::GetExtent3D( OGREnvelope3D *psExtent3D, bool bForce ) psExtent3D->MinZ = std::numeric_limits::quiet_NaN(); psExtent3D->MaxZ = std::numeric_limits::quiet_NaN(); - err = OGR_L_GetExtent( hLayer, psExtent3D, bForce ); + OGREnvelope envelope2D; + err = OGR_L_GetExtent( hLayer, &envelope2D, bForce ); if ( err == OGRERR_NONE ) + { + psExtent3D->MinX = envelope2D.MinX; + psExtent3D->MinY = envelope2D.MinY; + psExtent3D->MaxX = envelope2D.MaxX; + psExtent3D->MaxY = envelope2D.MaxY; err = isSpatialiteEnabled(); + } if ( err == OGRERR_NONE ) { From db65e95a26f019dfc1d98a28bf8d153f01e0cc2a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:38:33 +0100 Subject: [PATCH 02/27] qgsgml/qgsgmlshema: avoid redefining same constant --- src/core/qgsgml.cpp | 4 ++++ src/core/qgsgmlschema.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/qgsgml.cpp b/src/core/qgsgml.cpp index 7cbb21a212ab..1453b8b70d20 100644 --- a/src/core/qgsgml.cpp +++ b/src/core/qgsgml.cpp @@ -43,7 +43,11 @@ using namespace nlohmann; +#ifndef NS_SEPARATOR_DEFINED +#define NS_SEPARATOR_DEFINED static const char NS_SEPARATOR = '?'; +#endif + static const char *GML_NAMESPACE = "http://www.opengis.net/gml"; static const char *GML32_NAMESPACE = "http://www.opengis.net/gml/3.2"; diff --git a/src/core/qgsgmlschema.cpp b/src/core/qgsgmlschema.cpp index d63ff481aae4..257923cb4f02 100644 --- a/src/core/qgsgmlschema.cpp +++ b/src/core/qgsgmlschema.cpp @@ -31,7 +31,11 @@ #include -const char NS_SEPARATOR = '?'; +#ifndef NS_SEPARATOR_DEFINED +#define NS_SEPARATOR_DEFINED +static const char NS_SEPARATOR = '?'; +#endif + #define GML_NAMESPACE QStringLiteral( "http://www.opengis.net/gml" ) From 820e75e84eb98a511f00a843362372a628c6f16a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:38:51 +0100 Subject: [PATCH 03/27] src/core/mesh: factor a common method --- src/core/mesh/qgsmeshadvancedediting.cpp | 39 +++++++------------- src/core/mesh/qgstopologicalmesh.cpp | 47 +++++++++++------------- src/core/mesh/qgstopologicalmesh.h | 9 +++++ 3 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/core/mesh/qgsmeshadvancedediting.cpp b/src/core/mesh/qgsmeshadvancedediting.cpp index 3f72f9cc22bf..9acadd881aeb 100644 --- a/src/core/mesh/qgsmeshadvancedediting.cpp +++ b/src/core/mesh/qgsmeshadvancedediting.cpp @@ -62,19 +62,6 @@ QString QgsMeshAdvancedEditing::text() const return QString(); } -static int vertexPositionInFace( int vertexIndex, const QgsMeshFace &face ) -{ - return face.indexOf( vertexIndex ); -} - -static int vertexPositionInFace( const QgsMesh &mesh, int vertexIndex, int faceIndex ) -{ - if ( faceIndex < 0 || faceIndex >= mesh.faceCount() ) - return -1; - - return vertexPositionInFace( vertexIndex, mesh.face( faceIndex ) ); -} - QgsMeshEditRefineFaces::QgsMeshEditRefineFaces() = default; QgsTopologicalMesh::Changes QgsMeshEditRefineFaces::apply( QgsMeshEditor *meshEditor ) @@ -156,7 +143,7 @@ void QgsMeshEditRefineFaces::createNewVerticesAndRefinedFaces( QgsMeshEditor *me if ( neighborFaceIndex != -1 && facesToRefine.contains( neighborFaceIndex ) && canBeRefined( neighborFaceIndex ) ) { int neighborFaceSize = mesh.face( neighborFaceIndex ).size(); - int positionVertexInNeighbor = vertexPositionInFace( mesh, face.at( positionInFace ), neighborFaceIndex ); + int positionVertexInNeighbor = QgsTopologicalMesh::vertexPositionInFace( mesh, face.at( positionInFace ), neighborFaceIndex ); positionVertexInNeighbor = ( positionVertexInNeighbor + neighborFaceSize - 1 ) % neighborFaceSize; refinement.refinedFaceNeighbor[positionInFace] = true; QHash::iterator it = facesRefinement.find( neighborFaceIndex ); @@ -277,15 +264,15 @@ void QgsMeshEditRefineFaces::createNewVerticesAndRefinedFaces( QgsMeshEditor *me const FaceRefinement &otherRefinement = facesRefinement.value( neighborIndex ); const QgsMeshFace &otherFace = mesh.face( neighborIndex ); int otherFaceSize = otherFace.size(); - int otherPositionInface = ( vertexPositionInFace( firstVertexIndex, otherFace ) + otherFaceSize - 1 ) % otherFaceSize; + int otherPositionInface = ( QgsTopologicalMesh::vertexPositionInFace( firstVertexIndex, otherFace ) + otherFaceSize - 1 ) % otherFaceSize; int newFace1ChangesIndex = faceRefinement.newFacesChangesIndex.at( ( positionInFace ) ); const QgsMeshFace &newFace1 = mFacesToAdd.at( newFace1ChangesIndex ); - int positionInNewface1Index = vertexPositionInFace( firstVertexIndex, newFace1 ); + int positionInNewface1Index = QgsTopologicalMesh::vertexPositionInFace( firstVertexIndex, newFace1 ); int newFace2ChangesIndex = faceRefinement.newFacesChangesIndex.at( ( positionInFace + 1 ) % faceSize ); const QgsMeshFace &newFace2 = mFacesToAdd.at( newFace2ChangesIndex ); - int positionInNewface2Index = vertexPositionInFace( secondVertexIndex, newFace2 ); + int positionInNewface2Index = QgsTopologicalMesh::vertexPositionInFace( secondVertexIndex, newFace2 ); int otherNewFace1ChangesIndex = otherRefinement.newFacesChangesIndex.at( ( otherPositionInface ) % otherFaceSize ); int otherNewFace2ChangesIndex = otherRefinement.newFacesChangesIndex.at( ( otherPositionInface + 1 ) % otherFaceSize ); @@ -330,7 +317,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, { const QgsMeshFace &neighborFace = mesh.face( neighborFaceIndex ); int neighborFaceSize = neighborFace.size(); - int positionInNeighbor = vertexPositionInFace( mesh, faceToRefine.at( posInFaceToRefine ), neighborFaceIndex ); + int positionInNeighbor = QgsTopologicalMesh::vertexPositionInFace( mesh, faceToRefine.at( posInFaceToRefine ), neighborFaceIndex ); positionInNeighbor = ( positionInNeighbor + neighborFaceSize - 1 ) % neighborFaceSize; QHash::iterator it = borderFaces.find( neighborFaceIndex ); @@ -390,7 +377,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, { const QgsMeshFace &neighborFace = mesh.face( neighborIndex ); int neighborFaceSize = neighborFace.size(); - int posInNeighbor = vertexPositionInFace( mesh, face.at( posInFace ), neighborIndex ); + int posInNeighbor = QgsTopologicalMesh::vertexPositionInFace( mesh, face.at( posInFace ), neighborIndex ); posInNeighbor = ( posInNeighbor - 1 + neighborFaceSize ) % neighborFaceSize; QHash::iterator itRefinement = facesRefinement.find( neighborIndex ); @@ -503,7 +490,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, const FaceRefinement &faceRefinement = facesRefinement.value( refinedFaceIndex ); const QgsMeshFace &refinedFace = mesh.face( refinedFaceIndex ); int refinedFaceSize = refinedFace.size(); - int positionInRefinedFace = ( vertexPositionInFace( vertexIndexes[0], refinedFace ) + refinedFaceSize - 1 ) % refinedFaceSize; + int positionInRefinedFace = ( QgsTopologicalMesh::vertexPositionInFace( vertexIndexes[0], refinedFace ) + refinedFaceSize - 1 ) % refinedFaceSize; for ( int i = 0; i < 2; ++i ) { @@ -514,14 +501,14 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, // new refined faces are in place, so we can link neighborhood QgsTopologicalMesh::FaceNeighbors &neighborsNewFace = neighborhood[localFaceIndex.at( i )]; const QgsMeshFace newFace = faces.at( localFaceIndex.at( i ) ); - int positionInNewFace = vertexPositionInFace( vertexIndexes.at( i ), newFace ); + int positionInNewFace = QgsTopologicalMesh::vertexPositionInFace( vertexIndexes.at( i ), newFace ); int newFaceRefinedIndexInChanges = faceRefinement.newFacesChangesIndex.at( ( positionInRefinedFace + ( 1 - i ) ) % refinedFaceSize ) ; neighborsNewFace[positionInNewFace] = newFaceRefinedIndexInChanges + startingFaceChangesGlobalIndex; QgsTopologicalMesh::FaceNeighbors &neighborsRefinedFace = mFacesNeighborhoodToAdd[newFaceRefinedIndexInChanges]; const QgsMeshFace &newRefinedFace = mFacesToAdd.at( newFaceRefinedIndexInChanges ); int newRefinedFaceSize = newRefinedFace.size(); - int positionInNewRefinedChange = ( vertexPositionInFace( vertexIndexes.at( i ), newRefinedFace ) + newRefinedFaceSize - 1 ) % newRefinedFaceSize; + int positionInNewRefinedChange = ( QgsTopologicalMesh::vertexPositionInFace( vertexIndexes.at( i ), newRefinedFace ) + newRefinedFaceSize - 1 ) % newRefinedFaceSize; neighborsRefinedFace[positionInNewRefinedChange] = localFaceIndex.at( i ) + startingFaceIndex; } @@ -547,7 +534,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, int localFaceIndex = circulator.currentFaceIndex(); const QgsMeshFace &newFace = faces.at( localFaceIndex ); - int positionInNewface = vertexPositionInFace( vertexIndex, newFace ); + int positionInNewface = QgsTopologicalMesh::vertexPositionInFace( vertexIndex, newFace ); QgsTopologicalMesh::FaceNeighbors &neighborsNewFace = neighborhood[localFaceIndex]; int unchangedFaceIndex = neighborOfFace.at( positionInFace ); neighborsNewFace[positionInNewface] = unchangedFaceIndex; @@ -556,7 +543,7 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, { const QgsMeshFace &unchangedFace = mesh.face( unchangedFaceIndex ); int unchangedFaceSize = unchangedFace.size(); - int positionInUnchangedFace = ( vertexPositionInFace( vertexIndex, unchangedFace ) + unchangedFaceSize - 1 ) % unchangedFaceSize; + int positionInUnchangedFace = ( QgsTopologicalMesh::vertexPositionInFace( vertexIndex, unchangedFace ) + unchangedFaceSize - 1 ) % unchangedFaceSize; mNeighborhoodChanges.append( {unchangedFaceIndex, positionInUnchangedFace, faceIndex, localFaceIndex + startingFaceIndex} ); } @@ -594,13 +581,13 @@ bool QgsMeshEditRefineFaces::createNewBorderFaces( QgsMeshEditor *meshEditor, int otherIndex = neighbors.at( positionInFace ); const QgsMeshFace &otherFace = mesh.face( otherIndex ); int otherFaceSize = otherFace.size(); - int otherPositionInface = ( vertexPositionInFace( face.at( positionInFace ), otherFace ) + otherFaceSize - 1 ) % otherFaceSize; + int otherPositionInface = ( QgsTopologicalMesh::vertexPositionInFace( face.at( positionInFace ), otherFace ) + otherFaceSize - 1 ) % otherFaceSize; const BorderFace &otherBorderFace = borderFaces.value( otherIndex ); int otherNewFaceIndex = otherBorderFace.edgeFace.at( otherPositionInface ); int newFaceChangesIndex = borderFace.edgeFace.at( positionInFace ) - startingFaceChangesGlobalIndex; const QgsMeshFace &newFace = mFacesToAdd.at( newFaceChangesIndex ); - int newFacePositionInFace = vertexPositionInFace( face.at( positionInFace ), newFace ); + int newFacePositionInFace = QgsTopologicalMesh::vertexPositionInFace( face.at( positionInFace ), newFace ); mFacesNeighborhoodToAdd[newFaceChangesIndex][newFacePositionInFace] = otherNewFaceIndex; } diff --git a/src/core/mesh/qgstopologicalmesh.cpp b/src/core/mesh/qgstopologicalmesh.cpp index e6b040f7e067..a979f54aa0f1 100644 --- a/src/core/mesh/qgstopologicalmesh.cpp +++ b/src/core/mesh/qgstopologicalmesh.cpp @@ -24,17 +24,12 @@ #include #include -static int vertexPositionInFace( int vertexIndex, const QgsMeshFace &face ) -{ - return face.indexOf( vertexIndex ); -} - -static int vertexPositionInFace( const QgsMesh &mesh, int vertexIndex, int faceIndex ) +/*static*/ int QgsTopologicalMesh::vertexPositionInFace( const QgsMesh &mesh, int vertexIndex, int faceIndex ) { if ( faceIndex < 0 || faceIndex >= mesh.faceCount() ) return -1; - return vertexPositionInFace( vertexIndex, mesh.face( faceIndex ) ); + return QgsTopologicalMesh::vertexPositionInFace( vertexIndex, mesh.face( faceIndex ) ); } @@ -66,7 +61,7 @@ QgsMeshVertexCirculator::QgsMeshVertexCirculator( const QgsTopologicalMesh &topo if ( vertexIndex >= 0 && vertexIndex < topologicalMesh.mMesh->vertexCount() ) { mCurrentFace = topologicalMesh.mVertexToFace[vertexIndex]; - mIsValid = vertexPositionInFace( *topologicalMesh.mesh(), vertexIndex, mCurrentFace ) != -1; + mIsValid = QgsTopologicalMesh::vertexPositionInFace( *topologicalMesh.mesh(), vertexIndex, mCurrentFace ) != -1; } else { @@ -83,7 +78,7 @@ QgsMeshVertexCirculator::QgsMeshVertexCirculator( const QgsTopologicalMesh::Topo , mVertexIndex( vertexIndex ) { const QgsMeshFace &face = topologicalFaces.mFaces.at( faceIndex ); - mIsValid = vertexPositionInFace( vertexIndex, face ) != -1; + mIsValid = QgsTopologicalMesh::vertexPositionInFace( vertexIndex, face ) != -1; mCurrentFace = faceIndex; mLastValidFace = mCurrentFace; @@ -193,7 +188,7 @@ int QgsMeshVertexCirculator::oppositeVertexClockwise() const if ( face.isEmpty() ) return -1; - int vertexPosition = vertexPositionInFace( mVertexIndex, currentFace() ); + int vertexPosition = QgsTopologicalMesh::vertexPositionInFace( mVertexIndex, currentFace() ); if ( vertexPosition == -1 ) return -1; @@ -211,7 +206,7 @@ int QgsMeshVertexCirculator::oppositeVertexCounterClockwise() const if ( face.isEmpty() ) return -1; - int vertexPosition = vertexPositionInFace( mVertexIndex, currentFace() ); + int vertexPosition = QgsTopologicalMesh::vertexPositionInFace( mVertexIndex, currentFace() ); if ( vertexPosition == -1 ) return -1; @@ -281,7 +276,7 @@ int QgsMeshVertexCirculator::positionInCurrentFace() const if ( mCurrentFace < 0 || mCurrentFace >= mFaces.count() ) return -1; - return vertexPositionInFace( mVertexIndex, mFaces.at( mCurrentFace ) ); + return QgsTopologicalMesh::vertexPositionInFace( mVertexIndex, mFaces.at( mCurrentFace ) ); } QgsTopologicalMesh::Changes QgsTopologicalMesh::addFaces( const QgsTopologicalMesh::TopologicalFaces &topologicalFaces ) @@ -568,7 +563,7 @@ QgsMeshEditingError QgsTopologicalMesh::checkConsistency() const return QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidFace, faceIndex ); int neighborSize = neighborFace.size(); const FaceNeighbors &neighborhoodOfNeighbor = mFacesNeighborhood.at( neighborIndex ); - int posInNeighbor = vertexPositionInFace( *mMesh, vertexIndex, neighborIndex ); + int posInNeighbor = QgsTopologicalMesh::vertexPositionInFace( *mMesh, vertexIndex, neighborIndex ); if ( neighborhoodOfNeighbor.isEmpty() || neighborhoodOfNeighbor.at( ( posInNeighbor + neighborSize - 1 ) % neighborSize ) != faceIndex ) return QgsMeshEditingError( Qgis::MeshEditingErrorType::InvalidFace, faceIndex ); } @@ -2024,13 +2019,13 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::flipEdge( int vertexIndex1, int int pos2 = vertexPositionInFace( vertexIndex2, face2 ); int neighborFace1 = mFacesNeighborhood.at( faceIndex1 ).at( pos1 ); - int posInNeighbor1 = vertexPositionInFace( *mMesh, oppositeVertexFace1, neighborFace1 ); + int posInNeighbor1 = QgsTopologicalMesh::vertexPositionInFace( *mMesh, oppositeVertexFace1, neighborFace1 ); int neighborFace2 = mFacesNeighborhood.at( faceIndex1 ).at( ( pos1 + 1 ) % 3 ); - int posInNeighbor2 = vertexPositionInFace( *mMesh, vertexIndex2, neighborFace2 ); + int posInNeighbor2 = QgsTopologicalMesh::vertexPositionInFace( *mMesh, vertexIndex2, neighborFace2 ); int neighborFace3 = mFacesNeighborhood.at( faceIndex2 ).at( pos2 ); - int posInNeighbor3 = vertexPositionInFace( *mMesh, oppositeVertexFace2, neighborFace3 ); + int posInNeighbor3 = QgsTopologicalMesh::vertexPositionInFace( *mMesh, oppositeVertexFace2, neighborFace3 ); int neighborFace4 = mFacesNeighborhood.at( faceIndex2 ).at( ( pos2 + 1 ) % 3 ); - int posInNeighbor4 = vertexPositionInFace( *mMesh, vertexIndex1, neighborFace4 ); + int posInNeighbor4 = QgsTopologicalMesh::vertexPositionInFace( *mMesh, vertexIndex1, neighborFace4 ); changes.mFaceIndexesToRemove.append( faceIndex1 ); changes.mFaceIndexesToRemove.append( faceIndex2 ); @@ -2151,8 +2146,8 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::merge( int vertexIndex1, int ver int faceSize1 = face1.count(); int faceSize2 = face2.count(); - int pos1 = vertexPositionInFace( vertexIndex1, face1 ); - int pos2 = vertexPositionInFace( vertexIndex2, face2 ); + int pos1 = QgsTopologicalMesh::vertexPositionInFace( vertexIndex1, face1 ); + int pos2 = QgsTopologicalMesh::vertexPositionInFace( vertexIndex2, face2 ); changes.mFaceIndexesToRemove.append( faceIndex1 ); changes.mFaceIndexesToRemove.append( faceIndex2 ); @@ -2175,7 +2170,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::merge( int vertexIndex1, int ver if ( currentNeighbor != -1 ) { - int currentPosInNeighbor = vertexPositionInFace( *mMesh, face1.at( ( currentPos + 1 ) % faceSize1 ), currentNeighbor ); + int currentPosInNeighbor = QgsTopologicalMesh::vertexPositionInFace( *mMesh, face1.at( ( currentPos + 1 ) % faceSize1 ), currentNeighbor ); changes.mNeighborhoodChanges.append( {currentNeighbor, currentPosInNeighbor, faceIndex1, startIndex} ); } } @@ -2189,7 +2184,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::merge( int vertexIndex1, int ver if ( currentNeighbor != -1 ) { - int currentPosInNeighbor = vertexPositionInFace( *mMesh, face2.at( ( currentPos + 1 ) % faceSize2 ), currentNeighbor ); + int currentPosInNeighbor = QgsTopologicalMesh::vertexPositionInFace( *mMesh, face2.at( ( currentPos + 1 ) % faceSize2 ), currentNeighbor ); changes.mNeighborhoodChanges.append( {currentNeighbor, currentPosInNeighbor, faceIndex2, startIndex} ); } } @@ -2261,7 +2256,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::splitFace( int faceIndex ) for ( int i = 0; i < faceSize; ++i ) { neighborIndex[i] = mFacesNeighborhood.at( faceIndex ).at( ( splitVertexPos + i ) % faceSize ); - posInNeighbor[i] = vertexPositionInFace( *mMesh, face.at( ( splitVertexPos + i + 1 ) % faceSize ), neighborIndex[i] ); + posInNeighbor[i] = QgsTopologicalMesh::vertexPositionInFace( *mMesh, face.at( ( splitVertexPos + i + 1 ) % faceSize ), neighborIndex[i] ); } changes.mFaceIndexesToRemove.append( faceIndex ); @@ -2341,7 +2336,7 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::addVertexInFace( int includingFa if ( includingFaceNeighbor != -1 ) { - int indexInNeighbor = vertexPositionInFace( *mMesh, includingFace.at( ( i + 1 ) % includingFaceSize ), includingFaceNeighbor ); + int indexInNeighbor = QgsTopologicalMesh::vertexPositionInFace( *mMesh, includingFace.at( ( i + 1 ) % includingFaceSize ), includingFaceNeighbor ); int oldValue = mFacesNeighborhood[includingFaceNeighbor][indexInNeighbor]; mFacesNeighborhood[includingFaceNeighbor][indexInNeighbor] = changes.mAddedFacesFirstIndex + i; changes.mNeighborhoodChanges.append( {includingFaceNeighbor, indexInNeighbor, oldValue, changes.mAddedFacesFirstIndex + i} ); @@ -2472,15 +2467,15 @@ QgsTopologicalMesh::Changes QgsTopologicalMesh::insertVertexInFacesEdge( int fac edgeFacesIndexes[1] = newFaceBoundaryLocalIndex; } else - meshFaceBoundaryIndex = mFacesNeighborhood.at( removedFaceIndex ).at( vertexPositionInFace( vertexIndex, initialFace ) ); + meshFaceBoundaryIndex = mFacesNeighborhood.at( removedFaceIndex ).at( QgsTopologicalMesh::vertexPositionInFace( vertexIndex, initialFace ) ); const QgsMeshFace &newFace = circulator.currentFace(); - int positionInNewFaces = vertexPositionInFace( vertexIndex, newFace ); + int positionInNewFaces = QgsTopologicalMesh::vertexPositionInFace( vertexIndex, newFace ); if ( meshFaceBoundaryIndex != -1 ) { const QgsMeshFace meshFace = mMesh->face( meshFaceBoundaryIndex ); - int positionInMeshFaceBoundary = vertexPositionInFace( *mMesh, vertexIndex, meshFaceBoundaryIndex ); + int positionInMeshFaceBoundary = QgsTopologicalMesh::vertexPositionInFace( *mMesh, vertexIndex, meshFaceBoundaryIndex ); positionInMeshFaceBoundary = ( positionInMeshFaceBoundary - 1 + meshFace.count() ) % meshFace.count(); //take the position just before changes.mNeighborhoodChanges.append( {meshFaceBoundaryIndex, diff --git a/src/core/mesh/qgstopologicalmesh.h b/src/core/mesh/qgstopologicalmesh.h index 6b91e48b2267..d378a15ef7ff 100644 --- a/src/core/mesh/qgstopologicalmesh.h +++ b/src/core/mesh/qgstopologicalmesh.h @@ -331,6 +331,15 @@ class CORE_EXPORT QgsTopologicalMesh //! Checks the topology of the mesh \a mesh, if error occurs, this mesh can't be edited static QgsMeshEditingError checkTopology( const QgsMesh &mesh, int maxVerticesPerFace ); + //! Returns vertex position in face + static inline int vertexPositionInFace( int vertexIndex, const QgsMeshFace &face ) + { + return face.indexOf( vertexIndex ); + } + + //! Returns vertex position in face + static int vertexPositionInFace( const QgsMesh &mesh, int vertexIndex, int faceIndex ); + private: //! Creates topological faces from mesh faces From 2c953ff5bf699606265bc98cf04c2e5ab2b35982 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:39:13 +0100 Subject: [PATCH 04/27] src/core/geocoding: avoid same name for global constant --- src/core/geocoding/qgsgooglemapsgeocoder.cpp | 10 +++++----- src/core/geocoding/qgsnominatimgeocoder.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/geocoding/qgsgooglemapsgeocoder.cpp b/src/core/geocoding/qgsgooglemapsgeocoder.cpp index 4b830d93d02a..a13121473fce 100644 --- a/src/core/geocoding/qgsgooglemapsgeocoder.cpp +++ b/src/core/geocoding/qgsgooglemapsgeocoder.cpp @@ -30,7 +30,7 @@ QReadWriteLock QgsGoogleMapsGeocoder::sMutex; typedef QMap< QUrl, QList< QgsGeocoderResult > > CachedGeocodeResult; -Q_GLOBAL_STATIC( CachedGeocodeResult, sCachedResults ) +Q_GLOBAL_STATIC( CachedGeocodeResult, sCachedResultsGM ) QgsGoogleMapsGeocoder::QgsGoogleMapsGeocoder( const QString &apiKey, const QString ®ionBias ) @@ -91,8 +91,8 @@ QList QgsGoogleMapsGeocoder::geocodeString( const QString &st const QUrl url = requestUrl( string, bounds ); QgsReadWriteLocker locker( sMutex, QgsReadWriteLocker::Read ); - const auto it = sCachedResults()->constFind( url ); - if ( it != sCachedResults()->constEnd() ) + const auto it = sCachedResultsGM()->constFind( url ); + if ( it != sCachedResultsGM()->constEnd() ) { return *it; } @@ -142,7 +142,7 @@ QList QgsGoogleMapsGeocoder::geocodeString( const QString &st const QVariantList results = res.value( QStringLiteral( "results" ) ).toList(); if ( results.empty() ) { - sCachedResults()->insert( url, QList() ); + sCachedResultsGM()->insert( url, QList() ); return QList(); } @@ -152,7 +152,7 @@ QList QgsGoogleMapsGeocoder::geocodeString( const QString &st { matches << jsonToResult( result.toMap() ); } - sCachedResults()->insert( url, matches ); + sCachedResultsGM()->insert( url, matches ); return matches; } diff --git a/src/core/geocoding/qgsnominatimgeocoder.cpp b/src/core/geocoding/qgsnominatimgeocoder.cpp index 90186ec6ed9d..5c7325df9c68 100644 --- a/src/core/geocoding/qgsnominatimgeocoder.cpp +++ b/src/core/geocoding/qgsnominatimgeocoder.cpp @@ -30,7 +30,7 @@ QMutex QgsNominatimGeocoder::sMutex; typedef QMap< QUrl, QList< QgsGeocoderResult > > CachedGeocodeResult; -Q_GLOBAL_STATIC( CachedGeocodeResult, sCachedResults ) +Q_GLOBAL_STATIC( CachedGeocodeResult, sCachedResultsNominatim ) qint64 QgsNominatimGeocoder::sLastRequestTimestamp = 0; QgsNominatimGeocoder::QgsNominatimGeocoder( const QString &countryCodes, const QString &endpoint ) @@ -92,8 +92,8 @@ QList QgsNominatimGeocoder::geocodeString( const QString &str const QUrl url = requestUrl( string, bounds ); const QMutexLocker locker( &sMutex ); - const auto it = sCachedResults()->constFind( url ); - if ( it != sCachedResults()->constEnd() ) + const auto it = sCachedResultsNominatim()->constFind( url ); + if ( it != sCachedResultsNominatim()->constEnd() ) { return *it; } @@ -129,7 +129,7 @@ QList QgsNominatimGeocoder::geocodeString( const QString &str const QVariantList results = doc.array().toVariantList(); if ( results.isEmpty() ) { - sCachedResults()->insert( url, QList() ); + sCachedResultsNominatim()->insert( url, QList() ); return QList(); } @@ -140,7 +140,7 @@ QList QgsNominatimGeocoder::geocodeString( const QString &str matches << jsonToResult( result.toMap() ); } - sCachedResults()->insert( url, matches ); + sCachedResultsNominatim()->insert( url, matches ); return matches; } From e72088eab51384866908eded4a1c7b0588b03247 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:39:42 +0100 Subject: [PATCH 05/27] src/core/numericformats: avoid potential one-definition-rule violation --- .../numericformats/qgsbasicnumericformat.cpp | 35 ++++++++++--------- .../qgscoordinatenumericformat.cpp | 33 +++++++++-------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/core/numericformats/qgsbasicnumericformat.cpp b/src/core/numericformats/qgsbasicnumericformat.cpp index e2f59d38c511..ae76e2bbda98 100644 --- a/src/core/numericformats/qgsbasicnumericformat.cpp +++ b/src/core/numericformats/qgsbasicnumericformat.cpp @@ -21,21 +21,24 @@ #include #include -struct formatter : std::numpunct -{ - formatter( QChar thousands, bool showThousands, QChar decimal ) - : mThousands( thousands.unicode() ) - , mDecimal( decimal.unicode() ) - , mShowThousands( showThousands ) - {} - wchar_t do_decimal_point() const override { return mDecimal; } - wchar_t do_thousands_sep() const override { return mThousands; } - std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; } - - wchar_t mThousands; - wchar_t mDecimal; - bool mShowThousands = true; -}; +namespace QgsBasicNumericFormat_ns +{ + struct formatter : std::numpunct + { + formatter( QChar thousands, bool showThousands, QChar decimal ) + : mThousands( thousands.unicode() ) + , mDecimal( decimal.unicode() ) + , mShowThousands( showThousands ) + {} + wchar_t do_decimal_point() const override { return mDecimal; } + wchar_t do_thousands_sep() const override { return mThousands; } + std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; } + + wchar_t mThousands; + wchar_t mDecimal; + bool mShowThousands = true; + }; +} QgsBasicNumericFormat::QgsBasicNumericFormat() { @@ -60,7 +63,7 @@ QString QgsBasicNumericFormat::formatDouble( double value, const QgsNumericForma { const QChar decimal = mDecimalSeparator.isNull() ? context.decimalSeparator() : mDecimalSeparator; std::basic_stringstream os; - os.imbue( std::locale( os.getloc(), new formatter( mThousandsSeparator.isNull() ? context.thousandsSeparator() : mThousandsSeparator, + os.imbue( std::locale( os.getloc(), new QgsBasicNumericFormat_ns::formatter( mThousandsSeparator.isNull() ? context.thousandsSeparator() : mThousandsSeparator, mShowThousandsSeparator, decimal ) ) ); diff --git a/src/core/numericformats/qgscoordinatenumericformat.cpp b/src/core/numericformats/qgscoordinatenumericformat.cpp index 632036764e73..389d19e88cb7 100644 --- a/src/core/numericformats/qgscoordinatenumericformat.cpp +++ b/src/core/numericformats/qgscoordinatenumericformat.cpp @@ -24,21 +24,24 @@ #include ///@cond PRIVATE -struct formatter : std::numpunct +namespace QgsGeographicCoordinateNumericFormat_ns { - formatter( QChar thousands, bool showThousands, QChar decimal ) - : mThousands( thousands.unicode() ) - , mDecimal( decimal.unicode() ) - , mShowThousands( showThousands ) - {} - wchar_t do_decimal_point() const override { return mDecimal; } - wchar_t do_thousands_sep() const override { return mThousands; } - std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; } - - wchar_t mThousands; - wchar_t mDecimal; - bool mShowThousands = true; -}; + struct formatter : std::numpunct + { + formatter( QChar thousands, bool showThousands, QChar decimal ) + : mThousands( thousands.unicode() ) + , mDecimal( decimal.unicode() ) + , mShowThousands( showThousands ) + {} + wchar_t do_decimal_point() const override { return mDecimal; } + wchar_t do_thousands_sep() const override { return mThousands; } + std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; } + + wchar_t mThousands; + wchar_t mDecimal; + bool mShowThousands = true; + }; +} ///@endcond QgsGeographicCoordinateNumericFormat::QgsGeographicCoordinateNumericFormat() @@ -69,7 +72,7 @@ QString QgsGeographicCoordinateNumericFormat::formatDouble( double value, const { const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator(); std::basic_stringstream os; - os.imbue( std::locale( os.getloc(), new formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(), + os.imbue( std::locale( os.getloc(), new QgsGeographicCoordinateNumericFormat_ns::formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(), false, decimal ) ) ); From 37c43d7913ed4238567b97cb9abb3a43a5c0a3da Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:40:30 +0100 Subject: [PATCH 06/27] qgspointcloudrequest.cpp: add explicit cast for qHash() to avoid a qHash(QgsFeature) to be a potential candidate --- src/core/pointcloud/qgspointcloudrequest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/pointcloud/qgspointcloudrequest.cpp b/src/core/pointcloud/qgspointcloudrequest.cpp index a0c439abce16..eaaf69a025cd 100644 --- a/src/core/pointcloud/qgspointcloudrequest.cpp +++ b/src/core/pointcloud/qgspointcloudrequest.cpp @@ -39,5 +39,5 @@ void QgsPointCloudRequest::setAttributes( const QgsPointCloudAttributeCollection uint qHash( const QgsPointCloudRequest &request ) { - return qHash( request.filterRect() ) ^ qHash( request.attributes().toFields() ); + return qHash( request.filterRect() ) ^ qHash( QVariant( request.attributes().toFields() ) ); } From a51d03e7b9b83de8ec54854743dc4f343898f068 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:41:02 +0100 Subject: [PATCH 07/27] Add missing #define CPL_SUPRESS_CPLUSPLUS --- src/core/providers/ogr/qgsgeopackagerasterwriter.cpp | 1 + src/core/providers/ogr/qgsogrconnpool.h | 2 ++ src/core/providers/ogr/qgsogrprovidermetadata.cpp | 4 ++++ src/core/providers/ogr/qgsogrproviderutils.h | 1 + 4 files changed, 8 insertions(+) diff --git a/src/core/providers/ogr/qgsgeopackagerasterwriter.cpp b/src/core/providers/ogr/qgsgeopackagerasterwriter.cpp index 9f8eb2a99b16..2d98bc26d948 100644 --- a/src/core/providers/ogr/qgsgeopackagerasterwriter.cpp +++ b/src/core/providers/ogr/qgsgeopackagerasterwriter.cpp @@ -16,6 +16,7 @@ ///@cond PRIVATE +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include "gdal.h" #include "gdal_utils.h" #include "qgsogrutils.h" diff --git a/src/core/providers/ogr/qgsogrconnpool.h b/src/core/providers/ogr/qgsogrconnpool.h index e1aff0dca4e5..8a3457a5946b 100644 --- a/src/core/providers/ogr/qgsogrconnpool.h +++ b/src/core/providers/ogr/qgsogrconnpool.h @@ -19,6 +19,8 @@ #include "qgsconnectionpool.h" #include "qgsogrprovidermetadata.h" #include "qgsogrproviderutils.h" + +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include #include "qgis_sip.h" #include diff --git a/src/core/providers/ogr/qgsogrprovidermetadata.cpp b/src/core/providers/ogr/qgsogrprovidermetadata.cpp index 10020ce345f8..63809a04911b 100644 --- a/src/core/providers/ogr/qgsogrprovidermetadata.cpp +++ b/src/core/providers/ogr/qgsogrprovidermetadata.cpp @@ -34,6 +34,7 @@ email : nyall dot dawson at gmail dot com #include "qgsproviderregistry.h" #include "qgsvectorfilewriter.h" +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include #include #include @@ -1254,4 +1255,7 @@ QgsProviderMetadata::ProviderCapabilities QgsOgrProviderMetadata::providerCapabi return FileBasedUris | SaveLayerMetadata; } +#undef TEXT_PROVIDER_KEY +#undef TEXT_PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/ogr/qgsogrproviderutils.h b/src/core/providers/ogr/qgsogrproviderutils.h index 3826c1bb40d5..6eb6164db2ee 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.h +++ b/src/core/providers/ogr/qgsogrproviderutils.h @@ -21,6 +21,7 @@ email : nyall dot dawson at gmail dot com #include "qgswkbtypes.h" #include "qgsvectordataprovider.h" +#define CPL_SUPRESS_CPLUSPLUS //#spellok #include #include From eaeaae8a6f444dd3c8fcfbcfacad00fcf796633b Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:41:32 +0100 Subject: [PATCH 08/27] Undefine #define at end of compilation units to avoid conflicts --- src/core/pointcloud/qgseptpointcloudindex.cpp | 3 +++ src/core/providers/copc/qgscopcprovider.cpp | 4 ++++ src/core/providers/ept/qgseptprovider.cpp | 4 ++++ src/core/providers/memory/qgsmemoryprovider.cpp | 3 +++ src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp | 3 +++ src/core/providers/sensorthings/qgssensorthingsconnection.h | 1 + src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp | 4 ++++ src/core/raster/qgsrasterdataprovider.cpp | 2 ++ src/core/raster/qgsrasterlayer.cpp | 2 ++ src/core/tiledscene/qgsquantizedmeshtiles.h | 5 ++++- 10 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/core/pointcloud/qgseptpointcloudindex.cpp b/src/core/pointcloud/qgseptpointcloudindex.cpp index 726438553cba..fcfca06de064 100644 --- a/src/core/pointcloud/qgseptpointcloudindex.cpp +++ b/src/core/pointcloud/qgseptpointcloudindex.cpp @@ -720,4 +720,7 @@ void QgsEptPointCloudIndex::copyCommonProperties( QgsEptPointCloudIndex *destina destination->mOriginalMetadata = mOriginalMetadata; } +#undef PROVIDER_KEY +#undef PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/copc/qgscopcprovider.cpp b/src/core/providers/copc/qgscopcprovider.cpp index 12d04199fc6b..b033c7850246 100644 --- a/src/core/providers/copc/qgscopcprovider.cpp +++ b/src/core/providers/copc/qgscopcprovider.cpp @@ -243,5 +243,9 @@ QgsProviderMetadata::ProviderMetadataCapabilities QgsCopcProviderMetadata::capab | ProviderMetadataCapability::PriorityForUri | ProviderMetadataCapability::QuerySublayers; } + +#undef PROVIDER_KEY +#undef PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/ept/qgseptprovider.cpp b/src/core/providers/ept/qgseptprovider.cpp index 37e25f885e06..e5eb904624df 100644 --- a/src/core/providers/ept/qgseptprovider.cpp +++ b/src/core/providers/ept/qgseptprovider.cpp @@ -255,5 +255,9 @@ QgsProviderMetadata::ProviderMetadataCapabilities QgsEptProviderMetadata::capabi | ProviderMetadataCapability::PriorityForUri | ProviderMetadataCapability::QuerySublayers; } + +#undef PROVIDER_KEY +#undef PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/memory/qgsmemoryprovider.cpp b/src/core/providers/memory/qgsmemoryprovider.cpp index f8aa6043e5a2..341517f74ea0 100644 --- a/src/core/providers/memory/qgsmemoryprovider.cpp +++ b/src/core/providers/memory/qgsmemoryprovider.cpp @@ -853,4 +853,7 @@ QList QgsMemoryProviderMetadata::supportedLayerTypes() const return { Qgis::LayerType::Vector }; } +#undef TEXT_PROVIDER_KEY +#undef TEXT_PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp b/src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp index 68b567a3c1ab..5ff999a774a5 100644 --- a/src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp +++ b/src/core/providers/meshmemory/qgsmeshmemorydataprovider.cpp @@ -629,4 +629,7 @@ QList QgsMeshMemoryProviderMetadata::supportedLayerTypes() cons return { Qgis::LayerType::Mesh }; } +#undef TEXT_PROVIDER_KEY +#undef TEXT_PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/providers/sensorthings/qgssensorthingsconnection.h b/src/core/providers/sensorthings/qgssensorthingsconnection.h index f1e015d4c7d6..75a632601f23 100644 --- a/src/core/providers/sensorthings/qgssensorthingsconnection.h +++ b/src/core/providers/sensorthings/qgssensorthingsconnection.h @@ -14,6 +14,7 @@ ***************************************************************************/ #ifndef QGSSENSORTHINGSCONNECTION_H +#define QGSSENSORTHINGSCONNECTION_H #define SIP_NO_FILE diff --git a/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp b/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp index 212e18536f7d..d3ac19d5d2e5 100644 --- a/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp +++ b/src/core/providers/vpc/qgsvirtualpointcloudprovider.cpp @@ -615,5 +615,9 @@ QgsProviderMetadata::ProviderMetadataCapabilities QgsVirtualPointCloudProviderMe | ProviderMetadataCapability::PriorityForUri | ProviderMetadataCapability::QuerySublayers; } + +#undef PROVIDER_KEY +#undef PROVIDER_DESCRIPTION + ///@endcond diff --git a/src/core/raster/qgsrasterdataprovider.cpp b/src/core/raster/qgsrasterdataprovider.cpp index 896be139a46b..d58648ad68d8 100644 --- a/src/core/raster/qgsrasterdataprovider.cpp +++ b/src/core/raster/qgsrasterdataprovider.cpp @@ -1050,3 +1050,5 @@ QString QgsRasterDataProvider::encodeVirtualRasterProviderUri( const VirtualRast uri.setQuery( query ); return QString( QUrl::toPercentEncoding( uri.toEncoded() ) ); } + +#undef ERR diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 3c610b837177..adecf663332f 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -2603,3 +2603,5 @@ bool QgsRasterLayer::update() } return isValid(); } + +#undef ERR diff --git a/src/core/tiledscene/qgsquantizedmeshtiles.h b/src/core/tiledscene/qgsquantizedmeshtiles.h index 62697dbfe8ed..b6187dfbaf06 100644 --- a/src/core/tiledscene/qgsquantizedmeshtiles.h +++ b/src/core/tiledscene/qgsquantizedmeshtiles.h @@ -14,7 +14,8 @@ * * ***************************************************************************/ -#pragma once +#ifndef QGSQUANTIZEDMESHTILED_H +#define QGSQUANTIZEDMESHTILED_H #include "qgis_core.h" #include "qgsexception.h" @@ -97,3 +98,5 @@ struct CORE_EXPORT QgsQuantizedMeshTile // Make sure to call removeDegenerateTriangles() beforehand! QgsMesh toMesh( QgsRectangle tileBounds ); }; + +#endif // QGSQUANTIZEDMESHTILED_H From 87b0b2f8b8c0411162723f8029599a63d4a4a8a2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 04:06:57 +0100 Subject: [PATCH 09/27] qgis.cpp: namespace str() and xstr() macros --- src/core/qgis.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index daaecd60047c..83911cfb21e8 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -35,8 +35,8 @@ #include #include -#define xstr(x) str(x) -#define str(x) #x +#define qgis_xstr(x) qgis_str(x) +#define qgis_str(x) #x // Version constants // @@ -305,7 +305,7 @@ int Qgis::geosVersionMinor() int Qgis::geosVersionPatch() { - static const int version = atoi( xstr( GEOS_VERSION_PATCH ) ); + static const int version = atoi( qgis_xstr( GEOS_VERSION_PATCH ) ); return version; } From f786afd8cbf2d265762df0ff3ad12dd835c6beb9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 04:36:16 +0100 Subject: [PATCH 10/27] QgsLayoutItemLabel: remove unused private member --- src/core/layout/qgslayoutitemlabel.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/layout/qgslayoutitemlabel.h b/src/core/layout/qgslayoutitemlabel.h index c7399f04c85f..d2159162a10b 100644 --- a/src/core/layout/qgslayoutitemlabel.h +++ b/src/core/layout/qgslayoutitemlabel.h @@ -251,8 +251,6 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem void updateBoundingRect(); private: - bool mFirstRender = true; - // Text QString mText; From ab2767df313051754ea9ad9971fe03933322f2d2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 03:42:20 +0100 Subject: [PATCH 11/27] src/core/CMakeLists.txt: enable UNITY_BUILD --- src/core/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1b4157a6700f..0d0606ada6d6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2341,6 +2341,14 @@ add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS target_precompile_headers(qgis_core PRIVATE $<$:qgis.h>) +set_target_properties(qgis_core PROPERTIES UNITY_BUILD ON) + +# Exclude below files because they include tiny_gltf.h with different #define settings +set_source_files_properties(tiledscene/qgsgltfutils.cpp + tiledscene/qgsquantizedmeshtiles.cpp + tiledscene/qgstiledscenelayerrenderer.cpp + PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) + # Add meshoptimizer if(WITH_INTERNAL_MESHOPTIMIZER) target_sources(qgis_core PRIVATE From 30d5f2e1ee12757e81ecb689cefd45abf86af2b7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:34:13 +0100 Subject: [PATCH 12/27] Make unity builds conditioned by ENABLE_UNITY_BUILDS that defaults to OFF --- CMakeLists.txt | 2 ++ src/core/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd4b57742bc2..3eedb9b4f40d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1080,6 +1080,8 @@ endif() # whether to install required system libs in the output package set(QGIS_INSTALL_SYS_LIBS TRUE CACHE BOOL "If set to TRUE install all required system libs in the output package") +option(ENABLE_UNITY_BUILDS "Enable Unity builds, that is compiling several .cpp files in the same compilation unit (EXPERIMENTAL. Not recommended for production builds)" OFF) + ############################################################# # Python diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0d0606ada6d6..8f987e445feb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2341,7 +2341,7 @@ add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS target_precompile_headers(qgis_core PRIVATE $<$:qgis.h>) -set_target_properties(qgis_core PROPERTIES UNITY_BUILD ON) +set_target_properties(qgis_core PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) # Exclude below files because they include tiny_gltf.h with different #define settings set_source_files_properties(tiledscene/qgsgltfutils.cpp From 3bb704f00a46af57a809c0e98a80d19167a6b5ee Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:34:46 +0100 Subject: [PATCH 13/27] src/gui/auth: factor common code to make it unity builds friendly --- src/gui/auth/qgsauthauthoritieseditor.cpp | 29 ++++------------- src/gui/auth/qgsauthcertificateinfo.cpp | 38 ++++++----------------- src/gui/auth/qgsauthguiutils.cpp | 18 +++++++++++ src/gui/auth/qgsauthguiutils.h | 6 ++++ src/gui/auth/qgsauthidentitieseditor.cpp | 21 ++----------- src/gui/auth/qgsauthserverseditor.cpp | 22 ++----------- src/gui/auth/qgsauthsslconfigwidget.cpp | 10 +----- src/gui/auth/qgsauthtrustedcasdialog.cpp | 21 ++----------- 8 files changed, 47 insertions(+), 118 deletions(-) diff --git a/src/gui/auth/qgsauthauthoritieseditor.cpp b/src/gui/auth/qgsauthauthoritieseditor.cpp index 6c653d1e8112..97fae3c8feab 100644 --- a/src/gui/auth/qgsauthauthoritieseditor.cpp +++ b/src/gui/auth/qgsauthauthoritieseditor.cpp @@ -97,14 +97,6 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent ) } } -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - void QgsAuthAuthoritiesEditor::setupCaCertsTree() { treeWidgetCAs->setColumnCount( 4 ); @@ -122,7 +114,7 @@ void QgsAuthAuthoritiesEditor::setupCaCertsTree() treeWidgetCAs, QStringList( QgsAuthCertUtils::getCaSourceName( QgsAuthCertUtils::InDatabase ) ), static_cast( QgsAuthAuthoritiesEditor::Section ) ); - setItemBold_( mDbCaSecItem ); + QgsAuthGuiUtils::setItemBold( mDbCaSecItem ); mDbCaSecItem->setFlags( Qt::ItemIsEnabled ); mDbCaSecItem->setExpanded( true ); treeWidgetCAs->insertTopLevelItem( 0, mDbCaSecItem ); @@ -131,7 +123,7 @@ void QgsAuthAuthoritiesEditor::setupCaCertsTree() treeWidgetCAs, QStringList( QgsAuthCertUtils::getCaSourceName( QgsAuthCertUtils::FromFile ) ), static_cast( QgsAuthAuthoritiesEditor::Section ) ); - setItemBold_( mFileCaSecItem ); + QgsAuthGuiUtils::setItemBold( mFileCaSecItem ); mFileCaSecItem->setFlags( Qt::ItemIsEnabled ); mFileCaSecItem->setExpanded( true ); treeWidgetCAs->insertTopLevelItem( 0, mFileCaSecItem ); @@ -140,7 +132,7 @@ void QgsAuthAuthoritiesEditor::setupCaCertsTree() treeWidgetCAs, QStringList( QgsAuthCertUtils::getCaSourceName( QgsAuthCertUtils::SystemRoot ) ), static_cast( QgsAuthAuthoritiesEditor::Section ) ); - setItemBold_( mRootCaSecItem ); + QgsAuthGuiUtils::setItemBold( mRootCaSecItem ); mRootCaSecItem->setFlags( Qt::ItemIsEnabled ); mRootCaSecItem->setExpanded( false ); treeWidgetCAs->insertTopLevelItem( 0, mRootCaSecItem ); @@ -160,18 +152,9 @@ void QgsAuthAuthoritiesEditor::refreshCaCertsView() populateCaCertsView(); } -static void removeChildren_( QTreeWidgetItem *item ) -{ - const auto constTakeChildren = item->takeChildren(); - for ( QTreeWidgetItem *child : constTakeChildren ) - { - delete child; - } -} - void QgsAuthAuthoritiesEditor::populateDatabaseCaCerts() { - removeChildren_( mDbCaSecItem ); + QgsAuthGuiUtils::removeChildren( mDbCaSecItem ); const bool expanded = mDbCaSecItem->isExpanded(); populateCaCertsSection( mDbCaSecItem, @@ -182,7 +165,7 @@ void QgsAuthAuthoritiesEditor::populateDatabaseCaCerts() void QgsAuthAuthoritiesEditor::populateFileCaCerts() { - removeChildren_( mFileCaSecItem ); + QgsAuthGuiUtils::removeChildren( mFileCaSecItem ); const bool expanded = mFileCaSecItem->isExpanded(); populateCaCertsSection( mFileCaSecItem, @@ -193,7 +176,7 @@ void QgsAuthAuthoritiesEditor::populateFileCaCerts() void QgsAuthAuthoritiesEditor::populateRootCaCerts() { - removeChildren_( mRootCaSecItem ); + QgsAuthGuiUtils::removeChildren( mRootCaSecItem ); const bool expanded = mRootCaSecItem->isExpanded(); populateCaCertsSection( mRootCaSecItem, diff --git a/src/gui/auth/qgsauthcertificateinfo.cpp b/src/gui/auth/qgsauthcertificateinfo.cpp index 46eafde89b8d..42c620534b8d 100644 --- a/src/gui/auth/qgsauthcertificateinfo.cpp +++ b/src/gui/auth/qgsauthcertificateinfo.cpp @@ -32,24 +32,6 @@ #include "qgsauthmanager.h" #include "qgslogger.h" - -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - -static void removeChildren_( QTreeWidgetItem *item ) -{ - const auto constTakeChildren = item->takeChildren(); - for ( QTreeWidgetItem *child : constTakeChildren ) - { - delete child; - } -} - QgsAuthCertInfo::QgsAuthCertInfo( const QSslCertificate &cert, bool manageCertTrust, QWidget *parent, @@ -326,7 +308,7 @@ void QgsAuthCertInfo::setUpCertDetailsTree() treeDetails, QStringList( tr( "General" ) ), static_cast( DetailsSection ) ); - setItemBold_( mSecGeneral ); + QgsAuthGuiUtils::setItemBold( mSecGeneral ); mSecGeneral->setFirstColumnSpanned( true ); mSecGeneral->setFlags( Qt::ItemIsEnabled ); mSecGeneral->setExpanded( true ); @@ -336,7 +318,7 @@ void QgsAuthCertInfo::setUpCertDetailsTree() treeDetails, QStringList( tr( "Details" ) ), static_cast( DetailsSection ) ); - setItemBold_( mSecDetails ); + QgsAuthGuiUtils::setItemBold( mSecDetails ); mSecDetails->setFirstColumnSpanned( true ); mSecDetails->setFlags( Qt::ItemIsEnabled ); mSecDetails->setExpanded( false ); @@ -353,7 +335,7 @@ void QgsAuthCertInfo::setUpCertDetailsTree() treeDetails, QStringList( tr( "PEM Text" ) ), static_cast( DetailsSection ) ); - setItemBold_( mSecPemText ); + QgsAuthGuiUtils::setItemBold( mSecPemText ); mSecPemText->setFirstColumnSpanned( true ); mSecPemText->setFlags( Qt::ItemIsEnabled ); mSecPemText->setExpanded( false ); @@ -448,7 +430,7 @@ void QgsAuthCertInfo::addFieldItem( QTreeWidgetItem *parent, const QString &fiel void QgsAuthCertInfo::populateInfoGeneralSection() { - removeChildren_( mSecGeneral ); + QgsAuthGuiUtils::removeChildren( mSecGeneral ); if ( mCurrentQCert.isNull() ) { @@ -522,11 +504,11 @@ void QgsAuthCertInfo::populateInfoGeneralSection() void QgsAuthCertInfo::populateInfoDetailsSection() { - removeChildren_( mGrpSubj ); - removeChildren_( mGrpIssu ); - removeChildren_( mGrpCert ); - removeChildren_( mGrpPkey ); - removeChildren_( mGrpExts ); + QgsAuthGuiUtils::removeChildren( mGrpSubj ); + QgsAuthGuiUtils::removeChildren( mGrpIssu ); + QgsAuthGuiUtils::removeChildren( mGrpCert ); + QgsAuthGuiUtils::removeChildren( mGrpPkey ); + QgsAuthGuiUtils::removeChildren( mGrpExts ); if ( mCurrentQCert.isNull() ) return; @@ -816,7 +798,7 @@ void QgsAuthCertInfo::populateInfoDetailsSection() void QgsAuthCertInfo::populateInfoPemTextSection() { - removeChildren_( mSecPemText ); + QgsAuthGuiUtils::removeChildren( mSecPemText ); if ( mCurrentQCert.isNull() ) return; diff --git a/src/gui/auth/qgsauthguiutils.cpp b/src/gui/auth/qgsauthguiutils.cpp index 6ea4efb01d6c..5b6dbd7405f1 100644 --- a/src/gui/auth/qgsauthguiutils.cpp +++ b/src/gui/auth/qgsauthguiutils.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "qgssettings.h" #include "qgsauthmanager.h" @@ -418,3 +419,20 @@ void QgsAuthGuiUtils::passwordHelperLoggingEnable( bool enabled, QgsMessageBar * Q_UNUSED( timeout ) QgsApplication::authManager()->setPasswordHelperLoggingEnabled( enabled ); } + +void QgsAuthGuiUtils::setItemBold( QTreeWidgetItem *item ) +{ + item->setFirstColumnSpanned( true ); + QFont secf( item->font( 0 ) ); + secf.setBold( true ); + item->setFont( 0, secf ); +} + +void QgsAuthGuiUtils::removeChildren( QTreeWidgetItem *item ) +{ + const auto constTakeChildren = item->takeChildren(); + for ( QTreeWidgetItem *child : constTakeChildren ) + { + delete child; + } +} diff --git a/src/gui/auth/qgsauthguiutils.h b/src/gui/auth/qgsauthguiutils.h index 58d76f8873f6..b81db978d46e 100644 --- a/src/gui/auth/qgsauthguiutils.h +++ b/src/gui/auth/qgsauthguiutils.h @@ -20,6 +20,7 @@ #include #include "qgis_gui.h" +class QTreeWidgetItem; class QWidget; class QgsMessageBar; @@ -108,6 +109,11 @@ class GUI_EXPORT QgsAuthGuiUtils //! Sets password helper logging enabled (enable/disable) static void passwordHelperLoggingEnable( bool enabled, QgsMessageBar *msgbar, int timeout = 0 ); + //! Call setFirstColumnSpanned(true) on the item and make its font bold + static void setItemBold( QTreeWidgetItem *item ); + + //! Remove the children of the passed item + static void removeChildren( QTreeWidgetItem *item ); }; // clazy:excludeall=qstring-allocations diff --git a/src/gui/auth/qgsauthidentitieseditor.cpp b/src/gui/auth/qgsauthidentitieseditor.cpp index 7aa3aef0f9ee..3b83516f78c5 100644 --- a/src/gui/auth/qgsauthidentitieseditor.cpp +++ b/src/gui/auth/qgsauthidentitieseditor.cpp @@ -76,14 +76,6 @@ QgsAuthIdentitiesEditor::QgsAuthIdentitiesEditor( QWidget *parent ) } } -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - void QgsAuthIdentitiesEditor::setupIdentitiesTree() { treeIdentities->setColumnCount( 3 ); @@ -99,24 +91,15 @@ void QgsAuthIdentitiesEditor::setupIdentitiesTree() treeIdentities, QStringList( tr( "Certificate Bundles" ) ), static_cast( QgsAuthIdentitiesEditor::Section ) ); - setItemBold_( mRootCertIdentItem ); + QgsAuthGuiUtils::setItemBold( mRootCertIdentItem ); mRootCertIdentItem->setFlags( Qt::ItemIsEnabled ); mRootCertIdentItem->setExpanded( true ); treeIdentities->insertTopLevelItem( 0, mRootCertIdentItem ); } -static void removeChildren_( QTreeWidgetItem *item ) -{ - const auto constTakeChildren = item->takeChildren(); - for ( QTreeWidgetItem *child : constTakeChildren ) - { - delete child; - } -} - void QgsAuthIdentitiesEditor::populateIdentitiesView() { - removeChildren_( mRootCertIdentItem ); + QgsAuthGuiUtils::removeChildren( mRootCertIdentItem ); populateIdentitiesSection( mRootCertIdentItem, QgsApplication::authManager()->certIdentities(), diff --git a/src/gui/auth/qgsauthserverseditor.cpp b/src/gui/auth/qgsauthserverseditor.cpp index f80f4e48aeee..9d5879a00fb5 100644 --- a/src/gui/auth/qgsauthserverseditor.cpp +++ b/src/gui/auth/qgsauthserverseditor.cpp @@ -76,15 +76,6 @@ QgsAuthServersEditor::QgsAuthServersEditor( QWidget *parent ) } } -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - - void QgsAuthServersEditor::setupSslConfigsTree() { treeServerConfigs->setColumnCount( 3 ); @@ -100,24 +91,15 @@ void QgsAuthServersEditor::setupSslConfigsTree() treeServerConfigs, QStringList( tr( "SSL Server Configurations" ) ), static_cast( QgsAuthServersEditor::Section ) ); - setItemBold_( mRootSslConfigItem ); + QgsAuthGuiUtils::setItemBold( mRootSslConfigItem ); mRootSslConfigItem->setFlags( Qt::ItemIsEnabled ); mRootSslConfigItem->setExpanded( true ); treeServerConfigs->insertTopLevelItem( 0, mRootSslConfigItem ); } -static void removeChildren_( QTreeWidgetItem *item ) -{ - const auto constTakeChildren = item->takeChildren(); - for ( QTreeWidgetItem *child : constTakeChildren ) - { - delete child; - } -} - void QgsAuthServersEditor::populateSslConfigsView() { - removeChildren_( mRootSslConfigItem ); + QgsAuthGuiUtils::removeChildren( mRootSslConfigItem ); populateSslConfigsSection( mRootSslConfigItem, QgsApplication::authManager()->sslCertCustomConfigs(), diff --git a/src/gui/auth/qgsauthsslconfigwidget.cpp b/src/gui/auth/qgsauthsslconfigwidget.cpp index 924f90df9cdc..c47ae8156616 100644 --- a/src/gui/auth/qgsauthsslconfigwidget.cpp +++ b/src/gui/auth/qgsauthsslconfigwidget.cpp @@ -29,14 +29,6 @@ #include "qgsapplication.h" -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - static const QString configFoundText_() { return QObject::tr( "Configuration loaded from database" ); } static const QString configNotFoundText_() { return QObject::tr( "Configuration not found in database" ); } @@ -104,7 +96,7 @@ QTreeWidgetItem *QgsAuthSslConfigWidget::addRootItem( const QString &label ) QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << label, static_cast( ConfigParent ) ); - setItemBold_( item ); + QgsAuthGuiUtils::setItemBold( item ); item->setTextAlignment( 0, Qt::AlignVCenter ); item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); treeSslConfig->insertTopLevelItem( treeSslConfig->topLevelItemCount(), item ); diff --git a/src/gui/auth/qgsauthtrustedcasdialog.cpp b/src/gui/auth/qgsauthtrustedcasdialog.cpp index 94555e01373f..4227f6caafba 100644 --- a/src/gui/auth/qgsauthtrustedcasdialog.cpp +++ b/src/gui/auth/qgsauthtrustedcasdialog.cpp @@ -70,14 +70,6 @@ QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent, } } -static void setItemBold_( QTreeWidgetItem *item ) -{ - item->setFirstColumnSpanned( true ); - QFont secf( item->font( 0 ) ); - secf.setBold( true ); - item->setFont( 0, secf ); -} - void QgsAuthTrustedCAsDialog::setupCaCertsTree() { treeTrustedCAs->setColumnCount( 3 ); @@ -93,24 +85,15 @@ void QgsAuthTrustedCAsDialog::setupCaCertsTree() treeTrustedCAs, QStringList( tr( "Authorities/Issuers" ) ), static_cast( QgsAuthTrustedCAsDialog::Section ) ); - setItemBold_( mRootCaSecItem ); + QgsAuthGuiUtils::setItemBold( mRootCaSecItem ); mRootCaSecItem->setFlags( Qt::ItemIsEnabled ); mRootCaSecItem->setExpanded( true ); treeTrustedCAs->insertTopLevelItem( 0, mRootCaSecItem ); } -static void removeChildren_( QTreeWidgetItem *item ) -{ - const auto constTakeChildren = item->takeChildren(); - for ( QTreeWidgetItem *child : constTakeChildren ) - { - delete child; - } -} - void QgsAuthTrustedCAsDialog::populateCaCertsView() { - removeChildren_( mRootCaSecItem ); + QgsAuthGuiUtils::removeChildren( mRootCaSecItem ); if ( mTrustedCAs.isEmpty() ) { From 6d203847e857575b1a5480e862cc8ca7c24da5be Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:56:00 +0100 Subject: [PATCH 14/27] QgsMapLayerConfigWidget/QgsRendererRasterPropertiesWidget: suppress -Woverloaded-virtual warning related to syncToLayer() method --- .../gui/auto_generated/qgsmaplayerconfigwidget.sip.in | 1 + .../gui/auto_generated/qgsmaplayerconfigwidget.sip.in | 1 + src/gui/qgsmaplayerconfigwidget.h | 8 ++++++++ src/gui/raster/qgsrendererrasterpropertieswidget.h | 10 +++++----- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/python/PyQt6/gui/auto_generated/qgsmaplayerconfigwidget.sip.in b/python/PyQt6/gui/auto_generated/qgsmaplayerconfigwidget.sip.in index 8f3d61d31dba..665cf69a8477 100644 --- a/python/PyQt6/gui/auto_generated/qgsmaplayerconfigwidget.sip.in +++ b/python/PyQt6/gui/auto_generated/qgsmaplayerconfigwidget.sip.in @@ -123,6 +123,7 @@ be called for the layer after applying changes. This is ``True`` by default, but .. versionadded:: 3.8 %End + virtual void syncToLayer( QgsMapLayer *layer ); %Docstring Reset to original (vector layer) values diff --git a/python/gui/auto_generated/qgsmaplayerconfigwidget.sip.in b/python/gui/auto_generated/qgsmaplayerconfigwidget.sip.in index 8f3d61d31dba..665cf69a8477 100644 --- a/python/gui/auto_generated/qgsmaplayerconfigwidget.sip.in +++ b/python/gui/auto_generated/qgsmaplayerconfigwidget.sip.in @@ -123,6 +123,7 @@ be called for the layer after applying changes. This is ``True`` by default, but .. versionadded:: 3.8 %End + virtual void syncToLayer( QgsMapLayer *layer ); %Docstring Reset to original (vector layer) values diff --git a/src/gui/qgsmaplayerconfigwidget.h b/src/gui/qgsmaplayerconfigwidget.h index cd40b78c9fe4..338e2e0d4cfb 100644 --- a/src/gui/qgsmaplayerconfigwidget.h +++ b/src/gui/qgsmaplayerconfigwidget.h @@ -134,11 +134,19 @@ class GUI_EXPORT QgsMapLayerConfigWidget : public QgsPanelWidget */ virtual bool shouldTriggerLayerRepaint() const { return true; } +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + /** * Reset to original (vector layer) values * \since QGIS 3.14 */ virtual void syncToLayer( QgsMapLayer *layer ) { Q_UNUSED( layer ) } +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif /** * Sets the \a context under which the widget is being shown. diff --git a/src/gui/raster/qgsrendererrasterpropertieswidget.h b/src/gui/raster/qgsrendererrasterpropertieswidget.h index 1254d28df351..307b5bd71bbc 100644 --- a/src/gui/raster/qgsrendererrasterpropertieswidget.h +++ b/src/gui/raster/qgsrendererrasterpropertieswidget.h @@ -67,9 +67,9 @@ class GUI_EXPORT QgsRendererRasterPropertiesWidget : public QgsMapLayerConfigWid void apply() override; -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Woverloaded-virtual" +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" #endif /** @@ -77,8 +77,8 @@ class GUI_EXPORT QgsRendererRasterPropertiesWidget : public QgsMapLayerConfigWid * \param layer The layer to use for the widget */ void syncToLayer( QgsRasterLayer *layer ); -#ifdef __clang__ -#pragma clang diagnostic pop +#ifdef __GNUC__ +#pragma GCC diagnostic pop #endif private slots: From 9d3a9b0d1cae2bc01f4a2cdd977dd7f1f31a5c5a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 14:54:41 +0100 Subject: [PATCH 15/27] src/gui/editorwidgets: remove unused private members --- src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h | 1 - src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h | 1 - src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h | 1 - src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h | 1 - 4 files changed, 4 deletions(-) diff --git a/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h b/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h index 5543089b1d68..c23c2559b0fc 100644 --- a/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgscheckboxsearchwidgetwrapper.h @@ -79,7 +79,6 @@ class GUI_EXPORT QgsCheckboxSearchWidgetWrapper : public QgsSearchWidgetWrapper private: QCheckBox *mCheckBox = nullptr; - QgsVectorLayer *mLayer = nullptr; friend class QgsCheckboxWidgetFactory; }; diff --git a/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h b/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h index 8f7fb6d744ff..d3983eb71ba6 100644 --- a/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsdatetimesearchwidgetwrapper.h @@ -77,7 +77,6 @@ class GUI_EXPORT QgsDateTimeSearchWidgetWrapper : public QgsSearchWidgetWrapper private: QgsDateTimeEdit *mDateTimeEdit = nullptr; - QgsVectorLayer *mLayer = nullptr; friend class QgsDateTimeEditFactory; }; diff --git a/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h index 5299a078796f..0d7197bc4dcb 100644 --- a/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h @@ -67,7 +67,6 @@ class GUI_EXPORT QgsValueRelationSearchWidgetWrapper : public QgsSearchWidgetWra QLineEdit *mLineEdit = nullptr; QgsValueRelationFieldFormatter::ValueRelationCache mCache; - QgsVectorLayer *mLayer = nullptr; friend class QgsValueRelationWidgetFactory; }; diff --git a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h index c764603d47ec..ffec9cd8b46c 100644 --- a/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h +++ b/src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h @@ -226,7 +226,6 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper int mSubWidgetSignalBlocking = 0; //! Set to non-zero when a endless loop of notifications could happen. QgsValueRelationFieldFormatter::ValueRelationCache mCache; - QgsVectorLayer *mLayer = nullptr; bool mEnabled = true; QString mExpression; From 6015f503ee225809f7a47b7b4ac6d3d5d62ebdf9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:35:01 +0100 Subject: [PATCH 16/27] src/gui: use unity builds if ENABLE_UNITY_BUILDS --- src/gui/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 08db60f49961..1cbb9af209c3 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1680,6 +1680,8 @@ target_compile_features(qgis_gui PRIVATE cxx_std_17) target_precompile_headers(qgis_gui PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +set_target_properties(qgis_gui PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) + target_include_directories(qgis_gui SYSTEM PUBLIC ${QWT_INCLUDE_DIR} ${QSCINTILLA_INCLUDE_DIR} From 19509bbafcaba915cccc71ece38e004d8144fdc5 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:37:10 +0100 Subject: [PATCH 17/27] CI: set ENABLE_UNITY_BUILDS=ON for run-test.yml --- .docker/docker-qgis-build.sh | 1 + .github/workflows/run-tests.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.docker/docker-qgis-build.sh b/.docker/docker-qgis-build.sh index 5596eeb93359..db3a3cc0cd2b 100755 --- a/.docker/docker-qgis-build.sh +++ b/.docker/docker-qgis-build.sh @@ -89,6 +89,7 @@ cmake \ -DENABLE_MSSQLTEST=${WITH_QT5} \ -DENABLE_HANATEST=${WITH_QT5} \ -DENABLE_ORACLETEST=${WITH_QT5} \ + -DENABLE_UNITY_BUILDS=${ENABLE_UNITY_BUILDS} \ -DPUSH_TO_CDASH=${PUSH_TO_CDASH} \ -DWITH_HANA=ON \ -DWITH_QGIS_PROCESS=ON \ diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dcf2ee0d9d32..9ecba2fcc23e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -57,6 +57,7 @@ jobs: with-compile-commands: ON # LD_PRELOAD: /lib/x86_64-linux-gnu/libSegFault.so experimental: false + unity-builds: ON - distro-version: '39' qt-version: 6 @@ -73,6 +74,7 @@ jobs: with-compile-commands: OFF LD_PRELOAD: '' experimental: false + unity-builds: ON fail-fast: false @@ -165,6 +167,7 @@ jobs: --env LD_PRELOAD=${{ matrix.LD_PRELOAD }} \ --env WITH_CLAZY=${{ matrix.with-clazy }} \ --env WITH_COMPILE_COMMANDS=${{ matrix.with-compile-commands }} \ + --env ENABLE_UNITY_BUILDS=${{ matrix.unity-builds }} \ qgis3-build-deps \ /root/QGIS/.docker/docker-qgis-build.sh From a43a0769002aa404b0ced5db2358d892f3395a20 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 13:47:22 +0100 Subject: [PATCH 18/27] windows-qt6.yml: enable ENABLE_UNITY_BUILDS=ON --- .github/workflows/windows-qt6.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 735340239da2..39979ca7f971 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -73,6 +73,7 @@ jobs: -D ENABLE_TESTS=OFF \ -D BUILD_WITH_QT6=ON \ -D USE_CCACHE=ON \ + -D ENABLE_UNITY_BUILDS=ON \ -D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \ -D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \ -D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \ From 878ac1eb271050acc6528b4f513d88fbc70ff477 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 14:57:20 +0100 Subject: [PATCH 19/27] src/analysis: changes to allow unity builds --- .../processing/qgsalgorithmalignrasters.cpp | 27 ++++++------ .../qgsalgorithmalignsingleraster.cpp | 25 +++++------ .../qgsalgorithmrandompointsinpolygons.cpp | 13 ------ .../qgsalgorithmrandompointsinpolygons.h | 15 +++++++ .../qgsalgorithmrandompointsonlines.cpp | 14 ------ .../qgsalgorithmrandompointsonlines.h | 15 +++++++ .../qgsalgorithmzonalstatistics.cpp | 17 +------- .../qgsalgorithmzonalstatistics_private.h | 43 +++++++++++++++++++ ...gsalgorithmzonalstatisticsfeaturebased.cpp | 17 +------- 9 files changed, 101 insertions(+), 85 deletions(-) create mode 100644 src/analysis/processing/qgsalgorithmzonalstatistics_private.h diff --git a/src/analysis/processing/qgsalgorithmalignrasters.cpp b/src/analysis/processing/qgsalgorithmalignrasters.cpp index 8e33dc597d42..cfd29863833c 100644 --- a/src/analysis/processing/qgsalgorithmalignrasters.cpp +++ b/src/analysis/processing/qgsalgorithmalignrasters.cpp @@ -98,20 +98,6 @@ void QgsAlignRastersAlgorithm::initAlgorithm( const QVariantMap & ) addOutput( new QgsProcessingOutputMultipleLayers( QStringLiteral( "OUTPUT_LAYERS" ), QObject::tr( "Aligned rasters" ) ) ); } -struct QgsAlignRasterProgress : public QgsAlignRaster::ProgressHandler -{ - explicit QgsAlignRasterProgress( QgsFeedback *feedback ) : mFeedback( feedback ) {} - bool progress( double complete ) override - { - mFeedback->setProgress( complete * 100 ); - return true; - } - - protected: - QgsFeedback *mFeedback = nullptr; -}; - - QVariantMap QgsAlignRastersAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) { QgsRasterLayer *referenceLayer = parameterAsRasterLayer( parameters, QStringLiteral( "REFERENCE_LAYER" ), context ); @@ -172,6 +158,19 @@ QVariantMap QgsAlignRastersAlgorithm::processAlgorithm( const QVariantMap ¶m rasterAlign.setClipExtent( extent ); } + struct QgsAlignRasterProgress : public QgsAlignRaster::ProgressHandler + { + explicit QgsAlignRasterProgress( QgsFeedback *feedback ) : mFeedback( feedback ) {} + bool progress( double complete ) override + { + mFeedback->setProgress( complete * 100 ); + return true; + } + + protected: + QgsFeedback *mFeedback = nullptr; + }; + rasterAlign.setProgressHandler( new QgsAlignRasterProgress( feedback ) ); bool result = rasterAlign.setParametersFromRaster( referenceLayer->source(), customCRSWkt, customCellSize, customGridOffset ); diff --git a/src/analysis/processing/qgsalgorithmalignsingleraster.cpp b/src/analysis/processing/qgsalgorithmalignsingleraster.cpp index 683f3053b75c..92071489caa6 100644 --- a/src/analysis/processing/qgsalgorithmalignsingleraster.cpp +++ b/src/analysis/processing/qgsalgorithmalignsingleraster.cpp @@ -92,18 +92,6 @@ void QgsAlignSingleRasterAlgorithm::initAlgorithm( const QVariantMap & ) addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Aligned raster" ) ) ); } -struct QgsAlignRasterProgress : public QgsAlignRaster::ProgressHandler -{ - explicit QgsAlignRasterProgress( QgsFeedback *feedback ) : mFeedback( feedback ) {} - bool progress( double complete ) override - { - mFeedback->setProgress( complete * 100 ); - return true; - } - - protected: - QgsFeedback *mFeedback = nullptr; -}; QVariantMap QgsAlignSingleRasterAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) @@ -215,6 +203,19 @@ QVariantMap QgsAlignSingleRasterAlgorithm::processAlgorithm( const QVariantMap & rasterAlign.setClipExtent( extent ); } + struct QgsAlignRasterProgress : public QgsAlignRaster::ProgressHandler + { + explicit QgsAlignRasterProgress( QgsFeedback *feedback ) : mFeedback( feedback ) {} + bool progress( double complete ) override + { + mFeedback->setProgress( complete * 100 ); + return true; + } + + protected: + QgsFeedback *mFeedback = nullptr; + }; + rasterAlign.setProgressHandler( new QgsAlignRasterProgress( feedback ) ); bool result = rasterAlign.setParametersFromRaster( referenceLayer->source(), customCRSWkt, customCellSize, customGridOffset ); diff --git a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.cpp b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.cpp index 6fcc4d2205cb..8a166d11559c 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.cpp +++ b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.cpp @@ -21,19 +21,6 @@ #include -// The algorithm parameter names: -static const QString INPUT = QStringLiteral( "INPUT" ); -static const QString POINTS_NUMBER = QStringLiteral( "POINTS_NUMBER" ); -static const QString MIN_DISTANCE_GLOBAL = QStringLiteral( "MIN_DISTANCE_GLOBAL" ); -static const QString MIN_DISTANCE = QStringLiteral( "MIN_DISTANCE" ); -static const QString MAX_TRIES_PER_POINT = QStringLiteral( "MAX_TRIES_PER_POINT" ); -static const QString SEED = QStringLiteral( "SEED" ); -static const QString INCLUDE_POLYGON_ATTRIBUTES = QStringLiteral( "INCLUDE_POLYGON_ATTRIBUTES" ); -static const QString OUTPUT = QStringLiteral( "OUTPUT" ); -static const QString OUTPUT_POINTS = QStringLiteral( "OUTPUT_POINTS" ); -static const QString POINTS_MISSED = QStringLiteral( "POINTS_MISSED" ); -static const QString POLYGONS_WITH_MISSED_POINTS = QStringLiteral( "POLYGONS_WITH_MISSED_POINTS" ); -static const QString FEATURES_WITH_EMPTY_OR_NO_GEOMETRY = QStringLiteral( "FEATURES_WITH_EMPTY_OR_NO_GEOMETRY" ); ///@cond PRIVATE QString QgsRandomPointsInPolygonsAlgorithm::name() const diff --git a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h index 1d6f5e4b2d49..f1d8fac7a28d 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h +++ b/src/analysis/processing/qgsalgorithmrandompointsinpolygons.h @@ -52,6 +52,21 @@ class QgsRandomPointsInPolygonsAlgorithm : public QgsProcessingAlgorithm QgsProcessingFeedback *feedback ) override; private: + +// The algorithm parameter names: + static inline const QString INPUT = QStringLiteral( "INPUT" ); + static inline const QString POINTS_NUMBER = QStringLiteral( "POINTS_NUMBER" ); + static inline const QString MIN_DISTANCE_GLOBAL = QStringLiteral( "MIN_DISTANCE_GLOBAL" ); + static inline const QString MIN_DISTANCE = QStringLiteral( "MIN_DISTANCE" ); + static inline const QString MAX_TRIES_PER_POINT = QStringLiteral( "MAX_TRIES_PER_POINT" ); + static inline const QString SEED = QStringLiteral( "SEED" ); + static inline const QString INCLUDE_POLYGON_ATTRIBUTES = QStringLiteral( "INCLUDE_POLYGON_ATTRIBUTES" ); + static inline const QString OUTPUT = QStringLiteral( "OUTPUT" ); + static inline const QString OUTPUT_POINTS = QStringLiteral( "OUTPUT_POINTS" ); + static inline const QString POINTS_MISSED = QStringLiteral( "POINTS_MISSED" ); + static inline const QString POLYGONS_WITH_MISSED_POINTS = QStringLiteral( "POLYGONS_WITH_MISSED_POINTS" ); + static inline const QString FEATURES_WITH_EMPTY_OR_NO_GEOMETRY = QStringLiteral( "FEATURES_WITH_EMPTY_OR_NO_GEOMETRY" ); + int mNumPoints = 0; bool mDynamicNumPoints = false; QgsProperty mNumPointsProperty; diff --git a/src/analysis/processing/qgsalgorithmrandompointsonlines.cpp b/src/analysis/processing/qgsalgorithmrandompointsonlines.cpp index db48f921912e..af1d81c044f1 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsonlines.cpp +++ b/src/analysis/processing/qgsalgorithmrandompointsonlines.cpp @@ -21,20 +21,6 @@ #include -// The algorithm parameter names: -static const QString INPUT = QStringLiteral( "INPUT" ); -static const QString POINTS_NUMBER = QStringLiteral( "POINTS_NUMBER" ); -static const QString MIN_DISTANCE_GLOBAL = QStringLiteral( "MIN_DISTANCE_GLOBAL" ); -static const QString MIN_DISTANCE = QStringLiteral( "MIN_DISTANCE" ); -static const QString MAX_TRIES_PER_POINT = QStringLiteral( "MAX_TRIES_PER_POINT" ); -static const QString SEED = QStringLiteral( "SEED" ); -static const QString INCLUDE_LINE_ATTRIBUTES = QStringLiteral( "INCLUDE_LINE_ATTRIBUTES" ); -static const QString OUTPUT = QStringLiteral( "OUTPUT" ); -static const QString OUTPUT_POINTS = QStringLiteral( "OUTPUT_POINTS" ); -static const QString POINTS_MISSED = QStringLiteral( "POINTS_MISSED" ); -static const QString LINES_WITH_MISSED_POINTS = QStringLiteral( "LINES_WITH_MISSED_POINTS" ); -static const QString FEATURES_WITH_EMPTY_OR_NO_GEOMETRY = QStringLiteral( "FEATURES_WITH_EMPTY_OR_NO_GEOMETRY" ); - ///@cond PRIVATE QString QgsRandomPointsOnLinesAlgorithm::name() const diff --git a/src/analysis/processing/qgsalgorithmrandompointsonlines.h b/src/analysis/processing/qgsalgorithmrandompointsonlines.h index 36d6d63b93a6..66e2d6e7f0f0 100644 --- a/src/analysis/processing/qgsalgorithmrandompointsonlines.h +++ b/src/analysis/processing/qgsalgorithmrandompointsonlines.h @@ -54,6 +54,21 @@ class QgsRandomPointsOnLinesAlgorithm : public QgsProcessingAlgorithm private: + + // The algorithm parameter names: + static inline const QString INPUT = QStringLiteral( "INPUT" ); + static inline const QString POINTS_NUMBER = QStringLiteral( "POINTS_NUMBER" ); + static inline const QString MIN_DISTANCE_GLOBAL = QStringLiteral( "MIN_DISTANCE_GLOBAL" ); + static inline const QString MIN_DISTANCE = QStringLiteral( "MIN_DISTANCE" ); + static inline const QString MAX_TRIES_PER_POINT = QStringLiteral( "MAX_TRIES_PER_POINT" ); + static inline const QString SEED = QStringLiteral( "SEED" ); + static inline const QString INCLUDE_LINE_ATTRIBUTES = QStringLiteral( "INCLUDE_LINE_ATTRIBUTES" ); + static inline const QString OUTPUT = QStringLiteral( "OUTPUT" ); + static inline const QString OUTPUT_POINTS = QStringLiteral( "OUTPUT_POINTS" ); + static inline const QString POINTS_MISSED = QStringLiteral( "POINTS_MISSED" ); + static inline const QString LINES_WITH_MISSED_POINTS = QStringLiteral( "LINES_WITH_MISSED_POINTS" ); + static inline const QString FEATURES_WITH_EMPTY_OR_NO_GEOMETRY = QStringLiteral( "FEATURES_WITH_EMPTY_OR_NO_GEOMETRY" ); + int mNumPoints = 0; bool mDynamicNumPoints = false; QgsProperty mNumPointsProperty; diff --git a/src/analysis/processing/qgsalgorithmzonalstatistics.cpp b/src/analysis/processing/qgsalgorithmzonalstatistics.cpp index 9412f3d1e9db..fb1e6b2ea29b 100644 --- a/src/analysis/processing/qgsalgorithmzonalstatistics.cpp +++ b/src/analysis/processing/qgsalgorithmzonalstatistics.cpp @@ -18,25 +18,10 @@ #include "qgsalgorithmzonalstatistics.h" #include "qgszonalstatistics.h" #include "qgsvectorlayer.h" +#include "qgsalgorithmzonalstatistics_private.h" ///@cond PRIVATE -const std::vector< Qgis::ZonalStatistic > STATS -{ - Qgis::ZonalStatistic::Count, - Qgis::ZonalStatistic::Sum, - Qgis::ZonalStatistic::Mean, - Qgis::ZonalStatistic::Median, - Qgis::ZonalStatistic::StDev, - Qgis::ZonalStatistic::Min, - Qgis::ZonalStatistic::Max, - Qgis::ZonalStatistic::Range, - Qgis::ZonalStatistic::Minority, - Qgis::ZonalStatistic::Majority, - Qgis::ZonalStatistic::Variety, - Qgis::ZonalStatistic::Variance, -}; - QString QgsZonalStatisticsAlgorithm::name() const { return QStringLiteral( "zonalstatistics" ); diff --git a/src/analysis/processing/qgsalgorithmzonalstatistics_private.h b/src/analysis/processing/qgsalgorithmzonalstatistics_private.h new file mode 100644 index 000000000000..02d96c753c17 --- /dev/null +++ b/src/analysis/processing/qgsalgorithmzonalstatistics_private.h @@ -0,0 +1,43 @@ +/*************************************************************************** + qgsalgorithmzonalstatistics.cpp + --------------------- + begin : December 2019 + copyright : (C) 2019 by Alexander Bruy + email : alexander dot bruy at gmail dot com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSALGORITHMZONALSTATISTICS_PRIVATE_H +#define QGSALGORITHMZONALSTATISTICS_PRIVATE_H + +///@cond PRIVATE + +#include "qgis.h" + +const std::vector< Qgis::ZonalStatistic > STATS +{ + Qgis::ZonalStatistic::Count, + Qgis::ZonalStatistic::Sum, + Qgis::ZonalStatistic::Mean, + Qgis::ZonalStatistic::Median, + Qgis::ZonalStatistic::StDev, + Qgis::ZonalStatistic::Min, + Qgis::ZonalStatistic::Max, + Qgis::ZonalStatistic::Range, + Qgis::ZonalStatistic::Minority, + Qgis::ZonalStatistic::Majority, + Qgis::ZonalStatistic::Variety, + Qgis::ZonalStatistic::Variance, +}; + +///@endcond + +#endif diff --git a/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.cpp b/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.cpp index 7171e57763eb..b5176a84be0c 100644 --- a/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.cpp +++ b/src/analysis/processing/qgsalgorithmzonalstatisticsfeaturebased.cpp @@ -17,25 +17,10 @@ #include "qgsalgorithmzonalstatisticsfeaturebased.h" #include "qgszonalstatistics.h" +#include "qgsalgorithmzonalstatistics_private.h" ///@cond PRIVATE -const std::vector< Qgis::ZonalStatistic > STATS -{ - Qgis::ZonalStatistic::Count, - Qgis::ZonalStatistic::Sum, - Qgis::ZonalStatistic::Mean, - Qgis::ZonalStatistic::Median, - Qgis::ZonalStatistic::StDev, - Qgis::ZonalStatistic::Min, - Qgis::ZonalStatistic::Max, - Qgis::ZonalStatistic::Range, - Qgis::ZonalStatistic::Minority, - Qgis::ZonalStatistic::Majority, - Qgis::ZonalStatistic::Variety, - Qgis::ZonalStatistic::Variance, -}; - QString QgsZonalStatisticsFeatureBasedAlgorithm::name() const { return QStringLiteral( "zonalstatisticsfb" ); From 2469d0b4b3ecc5493b0c069906635bf71cc5ca45 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 14:57:05 +0100 Subject: [PATCH 20/27] src/analysis: use unity builds if ENABLE_UNITY_BUILDS --- src/analysis/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/analysis/CMakeLists.txt b/src/analysis/CMakeLists.txt index 18d503154375..13f228560f15 100644 --- a/src/analysis/CMakeLists.txt +++ b/src/analysis/CMakeLists.txt @@ -522,6 +522,8 @@ add_library(qgis_analysis ${LIBRARY_TYPE} ${QGIS_ANALYSIS_SRCS} ${QGIS_ANALYSIS_ target_precompile_headers(qgis_analysis PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +set_target_properties(qgis_analysis PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) + # require c++17 target_compile_features(qgis_analysis PRIVATE cxx_std_17) From 057b51d7cc3f455557528e9e046712df915fa25d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 17:03:36 +0100 Subject: [PATCH 21/27] src/3d: use unity builds if ENABLE_UNITY_BUILDS --- src/3d/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/3d/CMakeLists.txt b/src/3d/CMakeLists.txt index 4d9939d00825..a90d874afcdc 100644 --- a/src/3d/CMakeLists.txt +++ b/src/3d/CMakeLists.txt @@ -241,6 +241,8 @@ add_library(qgis_3d SHARED ${QGIS_3D_SRCS} ${QGIS_3D_HDRS} ${QGIS_3D_RCCS} ${QGI target_precompile_headers(qgis_3d PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +set_target_properties(qgis_3d PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) + # require c++17 target_compile_features(qgis_3d PRIVATE cxx_std_17) From 3ac1228c8f216ccda9fe995c9be5d6a32f58fe26 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 17:03:48 +0100 Subject: [PATCH 22/27] qgsdwgimporter.h: add import guard --- src/app/dwg/qgsdwgimporter.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/dwg/qgsdwgimporter.h b/src/app/dwg/qgsdwgimporter.h index 742d6fd839c3..ece66cb4ec2a 100644 --- a/src/app/dwg/qgsdwgimporter.h +++ b/src/app/dwg/qgsdwgimporter.h @@ -15,6 +15,9 @@ * * ***************************************************************************/ +#ifndef QGSDWGIMPORTER_H +#define QGSDWGIMPORTER_H + #include "drw_interface.h" #include @@ -226,3 +229,5 @@ class QgsDwgImporter : public DRW_Interface QTextCodec *mCodec = nullptr; QElapsedTimer mTime; }; + +#endif // QGSDWGIMPORTER_H From 5d8302b08e2b31d1989afa7cb8e258459cdf1ccf Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 17:03:57 +0100 Subject: [PATCH 23/27] src/app: use unity builds if ENABLE_UNITY_BUILDS --- src/app/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index f4d622a36ef1..5643c0ffd132 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -613,6 +613,8 @@ target_compile_definitions(qgis_app PRIVATE "-DQT_NO_FOREACH") target_precompile_headers(qgis_app PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +set_target_properties(qgis_app PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) + if (WITH_BINDINGS) add_definitions(-DWITH_BINDINGS) target_link_libraries(qgis_app qgispython) From cb3fec0f065adf13e9d6057e5f3f2278699b0efe Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 30 Nov 2024 17:07:12 +0100 Subject: [PATCH 24/27] src/server: use unity builds if ENABLE_UNITY_BUILDS --- src/server/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index debfae93dac8..f1a07f299830 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -88,6 +88,8 @@ add_library(qgis_server SHARED ${QGIS_SERVER_SRCS} ${QGIS_SERVER_HDRS}) target_precompile_headers(qgis_server PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +set_target_properties(qgis_server PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) + # require c++17 target_compile_features(qgis_server PRIVATE cxx_std_17) From a656e4df770bd40b62724b58b5b8a2f8ca03d9e1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 1 Dec 2024 16:37:32 +0100 Subject: [PATCH 25/27] Due to the introduction of precompiled headers, ccache builds require setting 'ccache -set-config sloppiness=pch_defines,time_macros' --- .ci/ogc/build.sh | 3 +++ .docker/docker-qgis-build.sh | 3 +++ .github/workflows/macos-build.yml | 2 ++ .github/workflows/windows-qt6.yml | 6 ++++++ CMakeLists.txt | 23 +++++++++++++++++++++-- ms-windows/mingw/build.sh | 3 +++ 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.ci/ogc/build.sh b/.ci/ogc/build.sh index 55787a7e3768..8e7558d45f59 100755 --- a/.ci/ogc/build.sh +++ b/.ci/ogc/build.sh @@ -13,6 +13,9 @@ ccache -M 2.0G # export CCACHE_LOGFILE=/tmp/cache.debug ccache -z +# To make ccache work properly with precompiled headers +ccache --set-config sloppiness=pch_defines,time_macros + cmake -GNinja \ -DUSE_CCACHE=ON \ -DWITH_QUICK=OFF \ diff --git a/.docker/docker-qgis-build.sh b/.docker/docker-qgis-build.sh index db3a3cc0cd2b..e76a5cc13bd0 100755 --- a/.docker/docker-qgis-build.sh +++ b/.docker/docker-qgis-build.sh @@ -18,6 +18,9 @@ ccache -M 2.0G # export CCACHE_LOGFILE=/tmp/cache.debug ccache -z +# To make ccache work properly with precompiled headers +ccache --set-config sloppiness=pch_defines,time_macros + ############################## # Variables for output styling ############################## diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 2b906bca633d..9eaeb4473740 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -108,6 +108,8 @@ jobs: mkdir -p ${CCACHE_DIR} brew install ccache ccache --set-config=max_size=2.0G + # To make ccache work properly with precompiled headers + ccache --set-config sloppiness=pch_defines,time_macros ccache -s - name: Run cmake diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 39979ca7f971..a27fc344bcff 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -53,6 +53,12 @@ jobs: key: build-ccache-win64-qt6-${{ github.event.pull_request.base.ref || github.ref_name }} save: ${{ github.event_name == 'push' }} + - name: 🛍️ Tune ccache configuration + shell: bash + run: | + # To make ccache work properly with precompiled headers + ccache --set-config sloppiness=pch_defines,time_macros + - name: 🌱 Install dependencies and generate project files shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eedb9b4f40d..e09a8243dcfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,9 +125,28 @@ option(USE_CCACHE "Use ccache" ON) if (USE_CCACHE) find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) message(STATUS "ccache found") + execute_process(COMMAND ccache --help OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_HELP) + execute_process(COMMAND ccache --get-config sloppiness OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_SLOPPINESS) + string(FIND "${CCACHE_SLOPPINESS}" "pch_defines" fpch_defines_found_index) + string(FIND "${CCACHE_SLOPPINESS}" "time_macros" time_macros_found_index) + # Detect if we have ccache >= 4.8 which accepts passing configuration settings when invoking the compiler + string(FIND "${CCACHE_HELP}" "ccache [KEY=VALUE ...] compiler" ccache_key_value_found_index) + if (ccache_key_value_found_index EQUAL -1 ) + if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1) + message(FATAL_ERROR "The use of precompiled headers only work if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=pch_defines,time_macros' to define them") + endif() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + else() + if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache sloppiness=pch_defines,time_macros") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache sloppiness=pch_defines,time_macros") + else() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + endif() + endif() endif(CCACHE_FOUND) endif(USE_CCACHE) diff --git a/ms-windows/mingw/build.sh b/ms-windows/mingw/build.sh index 9bc0d0e01c6f..93d8b966bf7c 100755 --- a/ms-windows/mingw/build.sh +++ b/ms-windows/mingw/build.sh @@ -67,6 +67,9 @@ fi installroot="$BUILDDIR/dist" installprefix="$installroot/usr/$arch-w64-mingw32/sys-root/mingw" +# To make ccache work properly with precompiled headers +ccache --set-config sloppiness=pch_defines,time_macros + # Cleanup rm -rf "$installroot" From 27b53606a746c6985ed8d3c5931bca002ea466ef Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 2 Dec 2024 02:19:57 +0100 Subject: [PATCH 26/27] Fix issue with .gch ccach'ing not working with QT6 and gcc --- .ci/ogc/build.sh | 2 +- .docker/docker-qgis-build.sh | 2 +- .github/workflows/macos-build.yml | 2 +- .github/workflows/windows-qt6.yml | 2 +- CMakeLists.txt | 41 +++++++++++++++++++++++-------- ms-windows/mingw/build.sh | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/.ci/ogc/build.sh b/.ci/ogc/build.sh index 8e7558d45f59..7bbfb6d43d24 100755 --- a/.ci/ogc/build.sh +++ b/.ci/ogc/build.sh @@ -14,7 +14,7 @@ ccache -M 2.0G ccache -z # To make ccache work properly with precompiled headers -ccache --set-config sloppiness=pch_defines,time_macros +ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime cmake -GNinja \ -DUSE_CCACHE=ON \ diff --git a/.docker/docker-qgis-build.sh b/.docker/docker-qgis-build.sh index e76a5cc13bd0..14da08465b35 100755 --- a/.docker/docker-qgis-build.sh +++ b/.docker/docker-qgis-build.sh @@ -19,7 +19,7 @@ ccache -M 2.0G ccache -z # To make ccache work properly with precompiled headers -ccache --set-config sloppiness=pch_defines,time_macros +ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime ############################## # Variables for output styling diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 9eaeb4473740..9395c1c73676 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -109,7 +109,7 @@ jobs: brew install ccache ccache --set-config=max_size=2.0G # To make ccache work properly with precompiled headers - ccache --set-config sloppiness=pch_defines,time_macros + ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime ccache -s - name: Run cmake diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index a27fc344bcff..1a78b66daf51 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -57,7 +57,7 @@ jobs: shell: bash run: | # To make ccache work properly with precompiled headers - ccache --set-config sloppiness=pch_defines,time_macros + ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime - name: 🌱 Install dependencies and generate project files shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index e09a8243dcfb..f49f239fee19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,25 +128,46 @@ if (USE_CCACHE) message(STATUS "ccache found") execute_process(COMMAND ccache --help OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_HELP) execute_process(COMMAND ccache --get-config sloppiness OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_SLOPPINESS) + execute_process(COMMAND ccache --get-config compiler_type OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CCACHE_COMPILER_TYPE) string(FIND "${CCACHE_SLOPPINESS}" "pch_defines" fpch_defines_found_index) string(FIND "${CCACHE_SLOPPINESS}" "time_macros" time_macros_found_index) + string(FIND "${CCACHE_SLOPPINESS}" "include_file_mtime" include_file_mtime_found_index) + string(FIND "${CCACHE_SLOPPINESS}" "include_file_ctime" include_file_ctime_found_index) # Detect if we have ccache >= 4.8 which accepts passing configuration settings when invoking the compiler string(FIND "${CCACHE_HELP}" "ccache [KEY=VALUE ...] compiler" ccache_key_value_found_index) + if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1 OR + (BUILD_WITH_QT6 AND (include_file_mtime_found_index EQUAL -1 OR include_file_ctime_found_index EQUAL -1))) + set(CCACHE_SLOPPINESS_REQUIRED "pch_defines,time_macros") + if (BUILD_WITH_QT6 AND (include_file_mtime_found_index EQUAL -1 OR include_file_ctime_found_index EQUAL -1)) + string(APPEND CCACHE_SLOPPINESS_REQUIRED ",include_file_mtime,include_file_ctime") + endif() + else() + set(CCACHE_SLOPPINESS_REQUIRED "") + endif() + if (BUILD_WITH_QT6 AND CMAKE_CXX_COMPILER STREQUAL "/usr/bin/c++" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT "${CCACHE_COMPILER_TYPE}" STREQUAL "gcc") + # Cf https://github.com/ccache/ccache/discussions/959 + set(CCACHE_COMPILER_TYPE_GCC_REQUIRED ON) + else() + set(CCACHE_COMPILER_TYPE_GCC_REQUIRED OFF) + endif() + set(CCACHE_INVOCATION_COMMAND "ccache") if (ccache_key_value_found_index EQUAL -1 ) - if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1) - message(FATAL_ERROR "The use of precompiled headers only work if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=pch_defines,time_macros' to define them") + if (CCACHE_SLOPPINESS_REQUIRED) + message(FATAL_ERROR "The use of precompiled headers only works if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=${CCACHE_SLOPPINESS_REQUIRED}' to define them") + endif() + if (CCACHE_COMPILER_TYPE_GCC_REQUIRED) + message(FATAL_ERROR "The use of precompiled headers only works properly with QT6 if the ccache 'compiler_type' settings is set to 'gcc'. Consider running 'ccache --set-config compiler_type=gcc'") endif() - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) else() - if (fpch_defines_found_index EQUAL -1 OR time_macros_found_index EQUAL -1) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache sloppiness=pch_defines,time_macros") - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache sloppiness=pch_defines,time_macros") - else() - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + if (CCACHE_SLOPPINESS_REQUIRED) + string(APPEND CCACHE_INVOCATION_COMMAND " sloppiness=${CCACHE_SLOPPINESS_REQUIRED}") + endif() + if (CCACHE_COMPILER_TYPE_GCC_REQUIRED) + string(APPEND CCACHE_INVOCATION_COMMAND " compiler_type=gcc") endif() endif() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_INVOCATION_COMMAND}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_INVOCATION_COMMAND}") endif(CCACHE_FOUND) endif(USE_CCACHE) diff --git a/ms-windows/mingw/build.sh b/ms-windows/mingw/build.sh index 93d8b966bf7c..c90e196b248f 100755 --- a/ms-windows/mingw/build.sh +++ b/ms-windows/mingw/build.sh @@ -68,7 +68,7 @@ installroot="$BUILDDIR/dist" installprefix="$installroot/usr/$arch-w64-mingw32/sys-root/mingw" # To make ccache work properly with precompiled headers -ccache --set-config sloppiness=pch_defines,time_macros +ccache --set-config sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime # Cleanup rm -rf "$installroot" From b546472e68bec5e25ae1337ea3f4dec352246ff0 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 2 Dec 2024 04:57:13 +0100 Subject: [PATCH 27/27] Do not enable pre-compiled headers when ccache is available and with MSVC, as ccache doesn't support that --- CMakeLists.txt | 12 +++++++++++- src/3d/CMakeLists.txt | 4 +++- src/analysis/CMakeLists.txt | 4 +++- src/app/CMakeLists.txt | 4 +++- src/core/CMakeLists.txt | 4 +++- src/gui/CMakeLists.txt | 4 +++- src/server/CMakeLists.txt | 4 +++- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f49f239fee19..d7b5be5f75b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,10 @@ if (USE_CCACHE) set(CCACHE_COMPILER_TYPE_GCC_REQUIRED OFF) endif() set(CCACHE_INVOCATION_COMMAND "ccache") - if (ccache_key_value_found_index EQUAL -1 ) + if (MSVC) + # CCache doesn't work yet with precompiled headers (cf https://github.com/ccache/ccache/issues/1383) + # so no need to set specific ccache configuration items + elseif (ccache_key_value_found_index EQUAL -1 ) if (CCACHE_SLOPPINESS_REQUIRED) message(FATAL_ERROR "The use of precompiled headers only works if the ccache 'sloppiness' settings contains 'pch_defines' and 'time_macros'. Consider running 'ccache --set-config sloppiness=${CCACHE_SLOPPINESS_REQUIRED}' to define them") endif() @@ -171,6 +174,13 @@ if (USE_CCACHE) endif(CCACHE_FOUND) endif(USE_CCACHE) +if (USE_CCACHE AND MSVC) + # CCache doesn't work yet with precompiled headers (cf https://github.com/ccache/ccache/issues/1383) + set(USE_PRECOMPILED_HEADERS OFF) +else() + set(USE_PRECOMPILED_HEADERS ON) +endif() + if (IOS) set (DEFAULT_FORCE_STATIC_LIBS TRUE) else() diff --git a/src/3d/CMakeLists.txt b/src/3d/CMakeLists.txt index a90d874afcdc..9c2d06f58016 100644 --- a/src/3d/CMakeLists.txt +++ b/src/3d/CMakeLists.txt @@ -239,7 +239,9 @@ set (QGIS_3D_RCCS shaders.qrc ../../resources/3d/textures/textures.qrc) add_library(qgis_3d SHARED ${QGIS_3D_SRCS} ${QGIS_3D_HDRS} ${QGIS_3D_RCCS} ${QGIS_3D_PRIVATE_HDRS}) -target_precompile_headers(qgis_3d PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_3d PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +endif() set_target_properties(qgis_3d PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) diff --git a/src/analysis/CMakeLists.txt b/src/analysis/CMakeLists.txt index 13f228560f15..b4739fe4cb65 100644 --- a/src/analysis/CMakeLists.txt +++ b/src/analysis/CMakeLists.txt @@ -520,7 +520,9 @@ endif() add_library(qgis_analysis ${LIBRARY_TYPE} ${QGIS_ANALYSIS_SRCS} ${QGIS_ANALYSIS_HDRS}) -target_precompile_headers(qgis_analysis PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_analysis PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +endif() set_target_properties(qgis_analysis PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 5643c0ffd132..fa5b9892cd56 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -611,7 +611,9 @@ target_link_libraries(qgis_app target_compile_definitions(qgis_app PRIVATE "-DQT_NO_FOREACH") -target_precompile_headers(qgis_app PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_app PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +endif() set_target_properties(qgis_app PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8f987e445feb..f0236b7b879a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2339,7 +2339,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_PRIVATE_HDRS} ${IMAGE_RCCS}) -target_precompile_headers(qgis_core PRIVATE $<$:qgis.h>) +if(USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_core PRIVATE $<$:qgis.h>) +endif() set_target_properties(qgis_core PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1cbb9af209c3..cbaa48455561 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1678,7 +1678,9 @@ add_library(qgis_gui ${LIBRARY_TYPE} # require c++17 target_compile_features(qgis_gui PRIVATE cxx_std_17) -target_precompile_headers(qgis_gui PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_gui PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +endif() set_target_properties(qgis_gui PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS}) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index f1a07f299830..de9ecf8fde6e 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -86,7 +86,9 @@ endif() add_library(qgis_server SHARED ${QGIS_SERVER_SRCS} ${QGIS_SERVER_HDRS}) -target_precompile_headers(qgis_server PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(qgis_server PRIVATE $<$:${CMAKE_SOURCE_DIR}/src/core/qgis.h>) +endif() set_target_properties(qgis_server PROPERTIES UNITY_BUILD ${ENABLE_UNITY_BUILDS})