Skip to content
Permalink
Browse files

[composer] Fixed assignment of map to legend + no updates when legend…

… is removed

Thanks to Nyall for his help!
  • Loading branch information
wonder-sk committed Oct 21, 2014
1 parent fe9c5c4 commit 0bda7143b1548814702fc9a1117612e8c4e92035
Showing with 13 additions and 8 deletions.
  1. +13 −8 src/core/composer/qgscomposerlegend.cpp
@@ -355,7 +355,7 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument
//composer map
if ( !itemElem.attribute( "map" ).isEmpty() )
{
mComposerMap = mComposition->getComposerMapById( itemElem.attribute( "map" ).toInt() );
setComposerMap( mComposition->getComposerMapById( itemElem.attribute( "map" ).toInt() ) );
}

QDomElement layerTreeElem = itemElem.firstChildElement( "layer-tree-group" );
@@ -442,7 +442,15 @@ QString QgsComposerLegend::displayName() const

void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )
{
if ( mComposerMap )
{
disconnect( mComposerMap, SIGNAL( destroyed( QObject* ) ), this, SLOT( invalidateCurrentMap() ) );
disconnect( mComposerMap, SIGNAL( itemChanged() ), this, SLOT( updateFilterByMap() ) );
disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( updateFilterByMap() ) );
}

mComposerMap = map;

if ( map )
{
QObject::connect( map, SIGNAL( destroyed( QObject* ) ), this, SLOT( invalidateCurrentMap() ) );
@@ -455,17 +463,14 @@ void QgsComposerLegend::setComposerMap( const QgsComposerMap* map )

void QgsComposerLegend::invalidateCurrentMap()
{
if ( mComposerMap )
{
disconnect( mComposerMap, SIGNAL( destroyed( QObject* ) ), this, SLOT( invalidateCurrentMap() ) );
disconnect( mComposerMap, SIGNAL( itemChanged() ), this, SLOT( updateFilterByMap() ) );
disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( updateFilterByMap() ) );
}
mComposerMap = 0;
setComposerMap( 0 );
}

void QgsComposerLegend::updateFilterByMap()
{
if ( isRemoved() )
return;

if ( mComposerMap && mLegendFilterByMap )
{
int dpi = mComposition->printResolution();

0 comments on commit 0bda714

Please sign in to comment.
You can’t perform that action at this time.