Skip to content

Commit eaad2e9

Browse files
YoannQDQnyalldawson
authored andcommitted
Apply suggestions from review
1 parent c17d4d8 commit eaad2e9

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

python/PyQt6/core/auto_generated/layout/qgslayoutitemnodeitem.sip.in

+5-4
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ Deselects any selected nodes.
111111
virtual double estimatedFrameBleed() const;
112112

113113

114-
115-
virtual bool isValid() const;
114+
virtual bool isValid() const = 0;
116115
%Docstring
117-
Can be reimplemented in subclasses. Typically a polyline is valid if it has at least 2 distinct nodes, while
118-
a polygon is valid if it has at least 3 distinct nodes.
116+
Must be reimplemented in subclasses.
117+
Typically a polyline is valid if it has at least 2 distinct nodes,
118+
while a polygon is valid if it has at least 3 distinct nodes.
119119

120120
.. versionadded:: 3.40
121121
%End
122+
122123
protected:
123124

124125
QgsLayoutNodesItem( QgsLayout *layout );

python/core/auto_generated/layout/qgslayoutitemnodeitem.sip.in

+5-4
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ Deselects any selected nodes.
111111
virtual double estimatedFrameBleed() const;
112112

113113

114-
115-
virtual bool isValid() const;
114+
virtual bool isValid() const = 0;
116115
%Docstring
117-
Can be reimplemented in subclasses. Typically a polyline is valid if it has at least 2 distinct nodes, while
118-
a polygon is valid if it has at least 3 distinct nodes.
116+
Must be reimplemented in subclasses.
117+
Typically a polyline is valid if it has at least 2 distinct nodes,
118+
while a polygon is valid if it has at least 3 distinct nodes.
119119

120120
.. versionadded:: 3.40
121121
%End
122+
122123
protected:
123124

124125
QgsLayoutNodesItem( QgsLayout *layout );

src/core/layout/qgslayoutitemnodeitem.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ class CORE_EXPORT QgsLayoutNodesItem: public QgsLayoutItem
113113
// rather than the item's pen
114114
double estimatedFrameBleed() const override;
115115

116-
117116
/**
118-
* Can be reimplemented in subclasses. Typically a polyline is valid if it has at least 2 distinct nodes, while
119-
* a polygon is valid if it has at least 3 distinct nodes.
117+
* Must be reimplemented in subclasses.
118+
* Typically a polyline is valid if it has at least 2 distinct nodes,
119+
* while a polygon is valid if it has at least 3 distinct nodes.
120120
*
121121
* \since QGIS 3.40
122122
*/
123-
virtual bool isValid() const { return true; };
123+
virtual bool isValid() const = 0;
124124

125125
protected:
126126

src/core/layout/qgslayoutitempolygon.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ QgsGeometry QgsLayoutItemPolygon::clipPath() const
132132

133133
bool QgsLayoutItemPolygon::isValid() const
134134
{
135+
// A Polygon is valid if it has at least 3 unique points
135136
QList<QPointF> uniquePoints;
136137
int seen = 0;
137138
for ( QPointF point : mPolygon )

src/core/layout/qgslayoutitempolyline.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ QPainterPath QgsLayoutItemPolyline::shape() const
341341

342342
bool QgsLayoutItemPolyline::isValid() const
343343
{
344+
// A Polyline is valid if it has at least 2 unique points
344345
QList<QPointF> uniquePoints;
345346
int seen = 0;
346347
for ( QPointF point : mPolygon )

src/gui/layout/qgslayoutviewtooladdnodeitem.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,22 @@ void QgsLayoutViewToolAddNodeItem::layoutPressEvent( QgsLayoutViewMouseEvent *ev
6969
// last (temporary) point is removed
7070
mPolygon.remove( mPolygon.count() - 1 );
7171

72-
QgsLayoutItem *item = QgsGui::layoutItemGuiRegistry()->createItem( mItemMetadataId, layout() );
72+
std::unique_ptr< QgsLayoutItem > item( QgsGui::layoutItemGuiRegistry()->createItem( mItemMetadataId, layout() ) );
7373
if ( !item )
7474
return;
7575

76-
if ( QgsLayoutNodesItem *nodesItem = qobject_cast< QgsLayoutNodesItem * >( item ) )
76+
if ( QgsLayoutNodesItem *nodesItem = qobject_cast< QgsLayoutNodesItem * >( item.get() ) )
7777
{
7878
nodesItem->setNodes( mPolygon );
7979
if ( !nodesItem->isValid() )
8080
{
81-
nodesItem->deleteLater();
8281
mRubberBand.reset();
8382
return;
8483
}
8584
}
86-
87-
layout()->addLayoutItem( item );
88-
layout()->setSelectedItem( item );
85+
QgsLayoutItem *newItem = item.get();
86+
layout()->addLayoutItem( item.release() );
87+
layout()->setSelectedItem( newItem );
8988
emit createdItem();
9089
}
9190
else

0 commit comments

Comments
 (0)