Skip to content
Permalink
Browse files

Fix crash with hidden dock widget

Fixes #17357
Fixes #17279
Fixes #17317
  • Loading branch information
m-kuhn committed Nov 2, 2017
1 parent 10c9bb6 commit 71eeda7b454ee1b83a9c63d96b2332ae5dde0ac4
Showing with 30 additions and 28 deletions.
  1. +30 −28 src/gui/qgsbrowserdockwidget.cpp
@@ -271,44 +271,46 @@ void QgsBrowserDockWidget::removeFavorite()

void QgsBrowserDockWidget::refresh()
{
if ( mModel )
refreshModel( QModelIndex() );
refreshModel( QModelIndex() );
}

void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
{
QgsDataItem *item = mModel->dataItem( index );
if ( item )
{
QgsDebugMsg( "path = " + item->path() );
}
else
{
QgsDebugMsg( "invalid item" );
}

if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
{
mModel->refresh( index );
}

for ( int i = 0; i < mModel->rowCount( index ); i++ )
if ( mModel && mProxyModel )
{
QModelIndex idx = mModel->index( i, 0, index );
QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
QgsDataItem *child = mModel->dataItem( idx );

// Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
// Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
QgsDataItem *item = mModel->dataItem( index );
if ( item )
{
refreshModel( idx );
QgsDebugMsg( "path = " + item->path() );
}
else
{
if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
QgsDebugMsg( "invalid item" );
}

if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
{
mModel->refresh( index );
}

for ( int i = 0; i < mModel->rowCount( index ); i++ )
{
QModelIndex idx = mModel->index( i, 0, index );
QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
QgsDataItem *child = mModel->dataItem( idx );

// Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
// Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
{
refreshModel( idx );
}
else
{
child->depopulate();
if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
{
child->depopulate();
}
}
}
}

0 comments on commit 71eeda7

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