From 47b812bb9b07fbe43898bc71c9a597115497db7d Mon Sep 17 00:00:00 2001 From: Juho Ervasti <118284595+JuhoErvasti@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:41:56 +0200 Subject: [PATCH] Don't allow non-polygon avoid intersection layers (#59331) --- python/PyQt6/core/auto_generated/project/qgsproject.sip.in | 1 + python/core/auto_generated/project/qgsproject.sip.in | 1 + src/core/project/qgsproject.cpp | 7 ++++++- src/core/project/qgsproject.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python/PyQt6/core/auto_generated/project/qgsproject.sip.in b/python/PyQt6/core/auto_generated/project/qgsproject.sip.in index 1dbf88302a37..79767e890d8e 100644 --- a/python/PyQt6/core/auto_generated/project/qgsproject.sip.in +++ b/python/PyQt6/core/auto_generated/project/qgsproject.sip.in @@ -1065,6 +1065,7 @@ A list of layers with which intersections should be avoided. %Docstring Sets the list of layers with which intersections should be avoided. Only used if the avoid intersection mode is set to advanced. +Line and point layers will not be added. %End void setAvoidIntersectionsMode( const Qgis::AvoidIntersectionsMode mode ); diff --git a/python/core/auto_generated/project/qgsproject.sip.in b/python/core/auto_generated/project/qgsproject.sip.in index 38ea98c94979..b1268483c092 100644 --- a/python/core/auto_generated/project/qgsproject.sip.in +++ b/python/core/auto_generated/project/qgsproject.sip.in @@ -1065,6 +1065,7 @@ A list of layers with which intersections should be avoided. %Docstring Sets the list of layers with which intersections should be avoided. Only used if the avoid intersection mode is set to advanced. +Line and point layers will not be added. %End void setAvoidIntersectionsMode( const Qgis::AvoidIntersectionsMode mode ); diff --git a/src/core/project/qgsproject.cpp b/src/core/project/qgsproject.cpp index 6f633e81cd01..5b9d515ef5d4 100644 --- a/src/core/project/qgsproject.cpp +++ b/src/core/project/qgsproject.cpp @@ -2824,8 +2824,13 @@ void QgsProject::setAvoidIntersectionsLayers( const QList &lay QStringList list; list.reserve( layers.size() ); + for ( QgsVectorLayer *layer : layers ) - list << layer->id(); + { + if ( layer->geometryType() == Qgis::GeometryType::Polygon ) + list << layer->id(); + } + writeEntry( QStringLiteral( "Digitizing" ), QStringLiteral( "/AvoidIntersectionsList" ), list ); emit avoidIntersectionsLayersChanged(); } diff --git a/src/core/project/qgsproject.h b/src/core/project/qgsproject.h index ab17d6c8c300..446d51870b8b 100644 --- a/src/core/project/qgsproject.h +++ b/src/core/project/qgsproject.h @@ -1113,6 +1113,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera /** * Sets the list of layers with which intersections should be avoided. * Only used if the avoid intersection mode is set to advanced. + * Line and point layers will not be added. * */ void setAvoidIntersectionsLayers( const QList &layers );