Skip to content

Commit

Permalink
Don't assume qobject_cast works on objects currently being deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 3, 2016
1 parent f3bfef4 commit dd715b2
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/core/qgsmaplayerregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
QString myId( lyr->id() );
emit layerWillBeRemoved( myId );
emit layerWillBeRemoved( lyr );
mMapLayers.remove( myId );
if ( lyr->parent() == this )
{
delete lyr;
}
mMapLayers.remove( myId );
emit layerRemoved( myId );
}

Expand Down Expand Up @@ -192,10 +192,7 @@ void QgsMapLayerRegistry::reloadAllLayers()

void QgsMapLayerRegistry::onMapLayerDeleted( QObject* obj )
{
QgsMapLayer* ml = qobject_cast<QgsMapLayer*>( obj );
Q_ASSERT( ml );

QString id = mMapLayers.key( ml );
QString id = mMapLayers.key( static_cast<QgsMapLayer*>( obj ) );

if ( !id.isNull() )
{
Expand Down

0 comments on commit dd715b2

Please sign in to comment.