Skip to content

Commit

Permalink
Get the vector layer pointer _before_ we close the layer properties a…
Browse files Browse the repository at this point in the history
…nd unset index
  • Loading branch information
nirvn committed Oct 21, 2023
1 parent 99692d0 commit 0d8ca2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/core/layertreemapcanvasbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ void LayerTreeMapCanvasBridge::mapThemeChanged()

void LayerTreeMapCanvasBridge::layerInTrackingChanged( QgsVectorLayer *layer, bool tracking )
{
QgsLayerTreeLayer *nodeLayer = mRoot->findLayer( layer->id() );
mModel->setLayerInTracking( nodeLayer, tracking );
if ( layer )
{
QgsLayerTreeLayer *nodeLayer = mRoot->findLayer( layer->id() );
mModel->setLayerInTracking( nodeLayer, tracking );
}
}
11 changes: 6 additions & 5 deletions src/qml/LayerTreeItemProperties.qml
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,19 @@ Popup {
icon.source: Theme.getThemeVectorIcon( 'directions_walk_24dp' )

onClicked: {
var layer = layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer)
close()

if ( trackingModel.layerInTracking( layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer) ) ) {
trackingModel.stopTracker(layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer));
displayToast( qsTr( 'Track on layer %1 stopped' ).arg( layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer).name ) )
if (trackingModel.layerInTracking(layer)) {
trackingModel.stopTracker(layer);
displayToast(qsTr('Track on layer %1 stopped').arg(layer.name))
} else {
var tracker;
var idx = projectInfo.restoreTracker(layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer))
var idx = projectInfo.restoreTracker(layer)
if (idx.valid) {
tracker = trackings.itemAt(idx.row).tracker
} else {
idx = trackingModel.createTracker(layerTree.data(index, FlatLayerTreeModel.VectorLayerPointer))
idx = trackingModel.createTracker(layer)
tracker = trackings.itemAt(idx.row).tracker
tracker.visible = itemVisibleCheckBox.checked
tracker.minimumDistance = positioningSettings.trackerMinimumDistanceConstraint ? positioningSettings.trackerMinimumDistance : 0
Expand Down

0 comments on commit 0d8ca2b

Please sign in to comment.