Skip to content

Commit

Permalink
When undo/redoing changes in QgsVectorLayer, ensure triggerRepaint
Browse files Browse the repository at this point in the history
signal is emitted so that layer is redrawn in **all** map canvases
  • Loading branch information
nyalldawson committed Dec 8, 2022
1 parent 3458bea commit 8c68d64
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/core/vector/qgsvectorlayereditbuffer.cpp
Expand Up @@ -58,6 +58,7 @@ void QgsVectorLayerEditBuffer::undoIndexChanged( int index )

QgsDebugMsgLevel( QStringLiteral( "undo index changed %1" ).arg( index ), 4 );
Q_UNUSED( index )
L->triggerRepaint();
emit layerModified();
}

Expand Down Expand Up @@ -167,9 +168,12 @@ bool QgsVectorLayerEditBuffer::addFeatures( QgsFeatureList &features )
mBlockModifiedSignals--;

if ( anyAdded )
{
emit layerModified();
L->triggerRepaint();
L->updateExtents();
}

L->updateExtents();
return result;
}

Expand Down Expand Up @@ -220,6 +224,7 @@ bool QgsVectorLayerEditBuffer::deleteFeatures( const QgsFeatureIds &fids )
ok = deleteFeature( fid ) && ok;

mBlockModifiedSignals--;
L->triggerRepaint();
emit layerModified();

return ok;
Expand Down Expand Up @@ -267,6 +272,7 @@ bool QgsVectorLayerEditBuffer::changeAttributeValues( QgsFeatureId fid, const Qg
}

mBlockModifiedSignals--;
L->triggerRepaint();
emit layerModified();

return success;
Expand Down
8 changes: 5 additions & 3 deletions tests/src/python/test_layer_dependencies.py
Expand Up @@ -217,8 +217,9 @@ def test_circular_dependencies_with_2_layers(self):

# repaintRequested is called on commit changes on point
# so it is on depending line
self.assertEqual(len(spy_lines_repaint_requested), 1)
self.assertEqual(len(spy_points_repaint_requested), 1)
# (ideally only one repaintRequested signal is fired, but it's harmless to fire multiple ones)
self.assertGreaterEqual(len(spy_lines_repaint_requested), 2)
self.assertGreaterEqual(len(spy_points_repaint_requested), 2)

def test_circular_dependencies_with_1_layer(self):

Expand Down Expand Up @@ -249,7 +250,8 @@ def test_circular_dependencies_with_1_layer(self):
self.assertEqual(len(spy_lines_data_changed), 4)

# repaintRequested is called only once on commit changes on line
self.assertEqual(len(spy_lines_repaint_requested), 1)
# (ideally only one repaintRequested signal is fired, but it's harmless to fire multiple ones)
self.assertGreaterEqual(len(spy_lines_repaint_requested), 2)

def test_layerDefinitionRewriteId(self):
tmpfile = os.path.join(tempfile.tempdir, "test.qlr")
Expand Down

0 comments on commit 8c68d64

Please sign in to comment.