Skip to content

Commit

Permalink
Fix #10594 (crashes when removing layers)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jun 18, 2014
1 parent 092265b commit 86860ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/layertree/qgslayertreeregistrybridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,13 @@ void QgsLayerTreeRegistryBridge::groupRemovedChildren()

QgsDebugMsg( QString( "%1 layers will be removed" ).arg( toRemove.count() ) );

QgsMapLayerRegistry::instance()->removeMapLayers( toRemove );
// delay the removal of layers from the registry. There may be other slots connected to map layer registry's signals
// that might disrupt the execution flow - e.g. a processEvents() call may force update of layer tree view with
// semi-broken tree model
QMetaObject::invokeMethod( this, "removeLayersFromRegistry", Qt::QueuedConnection, Q_ARG( QStringList, toRemove ) );
}

void QgsLayerTreeRegistryBridge::removeLayersFromRegistry( QStringList layerIds )
{
QgsMapLayerRegistry::instance()->removeMapLayers( layerIds );
}
2 changes: 2 additions & 0 deletions src/core/layertree/qgslayertreeregistrybridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
void groupWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
void groupRemovedChildren();

void removeLayersFromRegistry( QStringList layerIds );

protected:
QgsLayerTreeGroup* mRoot;
QStringList mLayerIdsForRemoval;
Expand Down

0 comments on commit 86860ce

Please sign in to comment.