@@ -49,7 +49,11 @@ void QgsMapToolNodeTool::createMovingRubberBands()
49
49
{
50
50
int topologicalEditing = QgsProject::instance ()->readNumEntry ( " Digitizing" , " /TopologicalEditing" , 0 );
51
51
52
- QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
52
+ Q_ASSERT ( mSelectedFeature );
53
+
54
+ QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
55
+ Q_ASSERT ( vlayer );
56
+
53
57
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature ->vertexMap ();
54
58
QgsGeometry* geometry = mSelectedFeature ->geometry ();
55
59
int beforeVertex, afterVertex;
@@ -84,7 +88,7 @@ void QgsMapToolNodeTool::createMovingRubberBands()
84
88
int index = 0 ;
85
89
if ( beforeVertex != -1 ) // adding first point which is not moving
86
90
{
87
- rb->addPoint ( toMapCoordinates ( mCanvas -> currentLayer () , vertexMap[beforeVertex]->point () ), false );
91
+ rb->addPoint ( toMapCoordinates ( vlayer , vertexMap[beforeVertex]->point () ), false );
88
92
vertexMap[beforeVertex]->setRubberBandValues ( true , lastRubberBand, index );
89
93
index ++;
90
94
}
@@ -96,15 +100,15 @@ void QgsMapToolNodeTool::createMovingRubberBands()
96
100
createTopologyRubberBands ( vlayer, vertexMap, vertex );
97
101
}
98
102
// adding point which will be moved
99
- rb->addPoint ( toMapCoordinates ( mCanvas -> currentLayer () , vertexMap[vertex]->point () ), false );
103
+ rb->addPoint ( toMapCoordinates ( vlayer , vertexMap[vertex]->point () ), false );
100
104
// setting values about added vertex
101
105
vertexMap[vertex]->setRubberBandValues ( true , lastRubberBand, index );
102
106
index ++;
103
107
geometry->adjacentVertices ( vertex, beforeVertex, vertex );
104
108
}
105
109
if ( vertex != -1 && !vertexMap[vertex]->isSelected () ) // add last point not moving if exists
106
110
{
107
- rb->addPoint ( toMapCoordinates ( mCanvas -> currentLayer () , vertexMap[vertex]->point () ), true );
111
+ rb->addPoint ( toMapCoordinates ( vlayer , vertexMap[vertex]->point () ), true );
108
112
vertexMap[vertex]->setRubberBandValues ( true , lastRubberBand, index );
109
113
index ++;
110
114
}
@@ -225,9 +229,8 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
225
229
if ( !mSelectedFeature || !mClicked )
226
230
return ;
227
231
228
- QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
229
- if ( !vlayer )
230
- return ;
232
+ QgsVectorLayer* vlayer = mSelectedFeature ->vlayer ();
233
+ Q_ASSERT ( vlayer );
231
234
232
235
mSelectAnother = false ;
233
236
@@ -347,13 +350,15 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
347
350
{
348
351
QgsDebugCall;
349
352
350
- QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
351
-
352
353
mClicked = true ;
353
354
mPressCoordinates = e->pos ();
354
355
QList<QgsSnappingResult> snapResults;
355
356
if ( !mSelectedFeature )
356
357
{
358
+ QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
359
+ if ( !vlayer )
360
+ return ;
361
+
357
362
mSelectAnother = false ;
358
363
mSnapper .snapToCurrentLayer ( e->pos (), snapResults, QgsSnapper::SnapToVertexAndSegment, -1 );
359
364
@@ -369,6 +374,9 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
369
374
}
370
375
else
371
376
{
377
+ QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
378
+ Q_ASSERT ( vlayer );
379
+
372
380
// some feature already selected
373
381
QgsPoint layerCoordPoint = toLayerCoordinates ( vlayer, e->pos () );
374
382
@@ -488,7 +496,8 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QMouseEvent * e )
488
496
489
497
removeRubberBands ();
490
498
491
- QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
499
+ QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
500
+ Q_ASSERT ( vlayer );
492
501
493
502
mClicked = false ;
494
503
mSelectionRectangle = false ;
@@ -626,10 +635,12 @@ void QgsMapToolNodeTool::removeRubberBands()
626
635
627
636
void QgsMapToolNodeTool::canvasDoubleClickEvent ( QMouseEvent * e )
628
637
{
629
- QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
630
- if ( !vlayer )
638
+ if ( !mSelectedFeature )
631
639
return ;
632
640
641
+ QgsVectorLayer *vlayer = mSelectedFeature ->vlayer ();
642
+ Q_ASSERT ( vlayer );
643
+
633
644
int topologicalEditing = QgsProject::instance ()->readNumEntry ( " Digitizing" , " /TopologicalEditing" , 0 );
634
645
QMultiMap<double , QgsSnappingResult> currentResultList;
635
646
0 commit comments