Skip to content

Commit 71eeda7

Browse files
committedNov 3, 2017
Fix crash with hidden dock widget
Fixes #17357 Fixes #17279 Fixes #17317
1 parent 10c9bb6 commit 71eeda7

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed
 

‎src/gui/qgsbrowserdockwidget.cpp

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -271,44 +271,46 @@ void QgsBrowserDockWidget::removeFavorite()
271271

272272
void QgsBrowserDockWidget::refresh()
273273
{
274-
if ( mModel )
275-
refreshModel( QModelIndex() );
274+
refreshModel( QModelIndex() );
276275
}
277276

278277
void QgsBrowserDockWidget::refreshModel( const QModelIndex &index )
279278
{
280-
QgsDataItem *item = mModel->dataItem( index );
281-
if ( item )
282-
{
283-
QgsDebugMsg( "path = " + item->path() );
284-
}
285-
else
286-
{
287-
QgsDebugMsg( "invalid item" );
288-
}
289-
290-
if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
291-
{
292-
mModel->refresh( index );
293-
}
294-
295-
for ( int i = 0; i < mModel->rowCount( index ); i++ )
279+
if ( mModel && mProxyModel )
296280
{
297-
QModelIndex idx = mModel->index( i, 0, index );
298-
QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
299-
QgsDataItem *child = mModel->dataItem( idx );
300-
301-
// Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
302-
// Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
303-
if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
281+
QgsDataItem *item = mModel->dataItem( index );
282+
if ( item )
304283
{
305-
refreshModel( idx );
284+
QgsDebugMsg( "path = " + item->path() );
306285
}
307286
else
308287
{
309-
if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
288+
QgsDebugMsg( "invalid item" );
289+
}
290+
291+
if ( item && ( item->capabilities2() & QgsDataItem::Fertile ) )
292+
{
293+
mModel->refresh( index );
294+
}
295+
296+
for ( int i = 0; i < mModel->rowCount( index ); i++ )
297+
{
298+
QModelIndex idx = mModel->index( i, 0, index );
299+
QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
300+
QgsDataItem *child = mModel->dataItem( idx );
301+
302+
// Check also expanded descendants so that the whole expanded path does not get collapsed if one item is collapsed.
303+
// Fast items (usually root items) are refreshed so that when collapsed, it is obvious they are if empty (no expand symbol).
304+
if ( mBrowserView->isExpanded( proxyIdx ) || mBrowserView->hasExpandedDescendant( proxyIdx ) || ( child && child->capabilities2() & QgsDataItem::Fast ) )
305+
{
306+
refreshModel( idx );
307+
}
308+
else
310309
{
311-
child->depopulate();
310+
if ( child && ( child->capabilities2() & QgsDataItem::Fertile ) )
311+
{
312+
child->depopulate();
313+
}
312314
}
313315
}
314316
}

0 commit comments

Comments
 (0)
Please sign in to comment.