Skip to content
Permalink
Browse files

browser: fix crash when removing favourite items from the directory t…

…ree (fixes #8236)
  • Loading branch information
jef-n committed Jul 9, 2013
1 parent f203105 commit 83cf4be9f68203c18949e4d548e0b3014ac99839
Showing with 10 additions and 2 deletions.
  1. +1 −1 src/app/qgsbrowserdockwidget.cpp
  2. +9 −1 src/core/qgsdataitem.cpp
@@ -308,7 +308,7 @@ void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )
QStringList favDirs = settings.value( "/browser/favourites" ).toStringList();
bool inFavDirs = favDirs.contains( item->path() );

if ( item->parent() != NULL && !inFavDirs )
if ( item->parent() && !inFavDirs )
{
// only non-root directories can be added as favourites
menu->addAction( tr( "Add as a favourite" ), this, SLOT( addFavourite() ) );
@@ -266,6 +266,7 @@ void QgsDataItem::deleteChildItem( QgsDataItem * child )

QgsDataItem * QgsDataItem::removeChildItem( QgsDataItem * child )
{
deleteChildItem( child );
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
int i = mChildren.indexOf( child );
Q_ASSERT( i >= 0 );
@@ -731,7 +732,14 @@ void QgsFavouritesItem::removeDirectory( QgsDirectoryItem *item )
favDirs.removeAll( item->path() );
settings.setValue( "/browser/favourites", favDirs );

deleteChildItem( item );
int idx = findItem( mChildren, item );
if ( idx < 0 )
{
QgsDebugMsg( QString( "favourites item %1 not found" ).arg( item->path() ) );
return;
}

deleteChildItem( mChildren[idx] );
}

//-----------------------------------------------------------------------

0 comments on commit 83cf4be

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