Skip to content
Permalink
Browse files

fix crash when moving layers

git-svn-id: http://svn.osgeo.org/qgis/trunk@13063 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 16, 2010
1 parent 74caf2f commit 72c7dd0b1d3934b7e7a5c1a12db8e71343ba4709
Showing with 15 additions and 9 deletions.
  1. +14 −8 src/app/legend/qgslegend.cpp
  2. +1 −1 src/app/legend/qgslegend.h
@@ -540,7 +540,7 @@ void QgsLegend::addLayer( QgsMapLayer * layer )

void QgsLegend::setMapCanvas( QgsMapCanvas * canvas )
{
if( mMapCanvas )
if ( mMapCanvas )
{
disconnect( mMapCanvas, SIGNAL( layersChanged() ) );
}
@@ -699,12 +699,18 @@ bool QgsLegend::removeLayer( QgsMapLayer* ml, bool askCancelOnEditable )

void QgsLegend::moveLayer( QgsMapLayer * ml, int groupIndex )
{
if ( !ml )
return;

QgsLegendLayer *layer = findLegendLayer( ml->getLayerID() );
if ( !layer )
return;

QgsLegendGroup *group = dynamic_cast<QgsLegendGroup*>( topLevelItem( groupIndex ) );
if ( layer && group )
{
insertItem( layer, group );
}
if ( !group )
return;

insertItem( layer, group );
}

void QgsLegend::legendLayerShowProperties()
@@ -1760,16 +1766,16 @@ QTreeWidgetItem * QgsLegend::lastVisibleItem()

void QgsLegend::refreshCheckStates()
{
if( !mMapCanvas )
if ( !mMapCanvas )
{
return;
}

QList<QgsMapLayer*> lst = mMapCanvas->layers();
for ( QTreeWidgetItem* item = firstItem(); item; item = nextItem( item ) )
for ( QTreeWidgetItem* item = firstItem(); item; item = nextItem( item ) )
{
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer *>( item );
if ( ll )
if ( ll )
{
ll->setCheckState( 0, ( lst.contains( ll->layer() ) ? Qt::Checked : Qt::Unchecked ) );
}
@@ -244,7 +244,7 @@ class QgsLegend : public QTreeWidget
* Moves a layer to a group.
* @param ml the maplayer to move
* @param groupIndex index of group
* @return false if the group does not exist, false otherwise
* @note keep in mind that the group's index changes, if the moved layer is above the group.
*/
void moveLayer( QgsMapLayer* ml, int groupIndex );

0 comments on commit 72c7dd0

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