@@ -355,7 +355,7 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument
355
355
// composer map
356
356
if ( !itemElem.attribute ( " map" ).isEmpty () )
357
357
{
358
- mComposerMap = mComposition ->getComposerMapById ( itemElem.attribute ( " map" ).toInt () );
358
+ setComposerMap ( mComposition ->getComposerMapById ( itemElem.attribute ( " map" ).toInt () ) );
359
359
}
360
360
361
361
QDomElement layerTreeElem = itemElem.firstChildElement ( " layer-tree-group" );
@@ -442,7 +442,15 @@ QString QgsComposerLegend::displayName() const
442
442
443
443
void QgsComposerLegend::setComposerMap ( const QgsComposerMap* map )
444
444
{
445
+ if ( mComposerMap )
446
+ {
447
+ disconnect ( mComposerMap , SIGNAL ( destroyed ( QObject* ) ), this , SLOT ( invalidateCurrentMap () ) );
448
+ disconnect ( mComposerMap , SIGNAL ( itemChanged () ), this , SLOT ( updateFilterByMap () ) );
449
+ disconnect ( mComposerMap , SIGNAL ( extentChanged () ), this , SLOT ( updateFilterByMap () ) );
450
+ }
451
+
445
452
mComposerMap = map;
453
+
446
454
if ( map )
447
455
{
448
456
QObject::connect ( map, SIGNAL ( destroyed ( QObject* ) ), this , SLOT ( invalidateCurrentMap () ) );
@@ -455,17 +463,14 @@ void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )
455
463
456
464
void QgsComposerLegend::invalidateCurrentMap ()
457
465
{
458
- if ( mComposerMap )
459
- {
460
- disconnect ( mComposerMap , SIGNAL ( destroyed ( QObject* ) ), this , SLOT ( invalidateCurrentMap () ) );
461
- disconnect ( mComposerMap , SIGNAL ( itemChanged () ), this , SLOT ( updateFilterByMap () ) );
462
- disconnect ( mComposerMap , SIGNAL ( extentChanged () ), this , SLOT ( updateFilterByMap () ) );
463
- }
464
- mComposerMap = 0 ;
466
+ setComposerMap ( 0 );
465
467
}
466
468
467
469
void QgsComposerLegend::updateFilterByMap ()
468
470
{
471
+ if ( isRemoved () )
472
+ return ;
473
+
469
474
if ( mComposerMap && mLegendFilterByMap )
470
475
{
471
476
int dpi = mComposition ->printResolution ();
0 commit comments