Skip to content

Commit

Permalink
browser: fix crash when removing favourite items from the directory t…
Browse files Browse the repository at this point in the history
…ree (fixes #8236)
  • Loading branch information
jef-n committed Jul 9, 2013
1 parent f203105 commit 83cf4be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -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() ) );
Expand Down
10 changes: 9 additions & 1 deletion src/core/qgsdataitem.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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] );
}

//-----------------------------------------------------------------------
Expand Down

0 comments on commit 83cf4be

Please sign in to comment.