Skip to content

Commit dd715b2

Browse files
committed
Don't assume qobject_cast works on objects currently being deleted
1 parent f3bfef4 commit dd715b2

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/core/qgsmaplayerregistry.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
151151
QString myId( lyr->id() );
152152
emit layerWillBeRemoved( myId );
153153
emit layerWillBeRemoved( lyr );
154+
mMapLayers.remove( myId );
154155
if ( lyr->parent() == this )
155156
{
156157
delete lyr;
157158
}
158-
mMapLayers.remove( myId );
159159
emit layerRemoved( myId );
160160
}
161161

@@ -192,10 +192,7 @@ void QgsMapLayerRegistry::reloadAllLayers()
192192

193193
void QgsMapLayerRegistry::onMapLayerDeleted( QObject* obj )
194194
{
195-
QgsMapLayer* ml = qobject_cast<QgsMapLayer*>( obj );
196-
Q_ASSERT( ml );
197-
198-
QString id = mMapLayers.key( ml );
195+
QString id = mMapLayers.key( static_cast<QgsMapLayer*>( obj ) );
199196

200197
if ( !id.isNull() )
201198
{

0 commit comments

Comments
 (0)