@@ -75,8 +75,11 @@ void QgsAppLegendInterface::removeGroup( int groupIndex )
75
75
parentGroup->removeChildNode ( group );
76
76
}
77
77
78
- void QgsAppLegendInterface::moveLayer ( QgsMapLayer * ml, int groupIndex )
78
+ void QgsAppLegendInterface::moveLayer ( QgsMapLayer *ml, int groupIndex )
79
79
{
80
+ if ( !ml )
81
+ return ;
82
+
80
83
QgsLayerTreeGroup* group = groupIndexToNode ( groupIndex );
81
84
if ( !group )
82
85
return ;
@@ -155,14 +158,20 @@ int QgsAppLegendInterface::groupNodeToIndex( QgsLayerTreeGroup* group )
155
158
return _groupNodeToIndex ( group, mLayerTreeView ->layerTreeModel ()->rootGroup (), currentIndex );
156
159
}
157
160
158
- void QgsAppLegendInterface::setLayerVisible ( QgsMapLayer * ml, bool visible )
161
+ void QgsAppLegendInterface::setLayerVisible ( QgsMapLayer *ml, bool visible )
159
162
{
163
+ if ( !ml )
164
+ return ;
165
+
160
166
if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView ->layerTreeModel ()->rootGroup ()->findLayer ( ml->id () ) )
161
167
nodeLayer->setVisible ( visible ? Qt::Checked : Qt::Unchecked );
162
168
}
163
169
164
170
void QgsAppLegendInterface::setLayerExpanded ( QgsMapLayer * ml, bool expand )
165
171
{
172
+ if ( !ml )
173
+ return ;
174
+
166
175
if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView ->layerTreeModel ()->rootGroup ()->findLayer ( ml->id () ) )
167
176
setExpanded ( nodeLayer, expand );
168
177
}
@@ -247,17 +256,23 @@ bool QgsAppLegendInterface::isGroupVisible( int groupIndex )
247
256
return false ;
248
257
}
249
258
250
- bool QgsAppLegendInterface::isLayerExpanded ( QgsMapLayer * ml )
259
+ bool QgsAppLegendInterface::isLayerExpanded ( QgsMapLayer *ml )
251
260
{
261
+ if ( !ml )
262
+ return false ;
263
+
252
264
if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView ->layerTreeModel ()->rootGroup ()->findLayer ( ml->id () ) )
253
265
return nodeLayer->isExpanded ();
254
266
255
267
return false ;
256
268
}
257
269
258
270
259
- bool QgsAppLegendInterface::isLayerVisible ( QgsMapLayer * ml )
271
+ bool QgsAppLegendInterface::isLayerVisible ( QgsMapLayer *ml )
260
272
{
273
+ if ( !ml )
274
+ return false ;
275
+
261
276
if ( QgsLayerTreeLayer* nodeLayer = mLayerTreeView ->layerTreeModel ()->rootGroup ()->findLayer ( ml->id () ) )
262
277
return nodeLayer->isVisible () == Qt::Checked;
263
278
@@ -283,6 +298,9 @@ QList< QgsMapLayer * > QgsAppLegendInterface::layers() const
283
298
284
299
void QgsAppLegendInterface::refreshLayerSymbology ( QgsMapLayer *ml )
285
300
{
301
+ if ( !ml )
302
+ return ;
303
+
286
304
mLayerTreeView ->refreshLayerSymbology ( ml->id () );
287
305
}
288
306
0 commit comments