Skip to content
Permalink
Browse files

Fix some crashes in processing toolbox model when loading/unloading p…

…lugins
  • Loading branch information
nyalldawson committed Jul 16, 2018
1 parent 5898854 commit 7933c85126baab5ca2fcadc93186dac9c519a63d
Showing with 6 additions and 24 deletions.
  1. +6 −24 src/gui/processing/qgsprocessingtoolboxmodel.cpp
@@ -123,7 +123,7 @@ QgsProcessingToolboxModel::QgsProcessingToolboxModel( QObject *parent, QgsProces
if ( mRecentLog )
connect( mRecentLog, &QgsProcessingRecentAlgorithmLog::changed, this, [ = ] { repopulateRecentAlgorithms(); } );

connect( mRegistry, &QgsProcessingRegistry::providerAdded, this, &QgsProcessingToolboxModel::providerAdded );
connect( mRegistry, &QgsProcessingRegistry::providerAdded, this, &QgsProcessingToolboxModel::rebuild );
connect( mRegistry, &QgsProcessingRegistry::providerRemoved, this, &QgsProcessingToolboxModel::providerRemoved );
}

@@ -235,29 +235,11 @@ void QgsProcessingToolboxModel::providerAdded( const QString &id )
}
}

void QgsProcessingToolboxModel::providerRemoved( const QString &id )
void QgsProcessingToolboxModel::providerRemoved( const QString & )
{
if ( isTopLevelProvider( id ) )
{
// native providers use top level groups - so we can't
// work out what to remove. Just rebuild the whole model instead.
rebuild();
}
else
{
// can't retrieve the provider - it's been deleted!
// so find node by id
QModelIndex index = indexForProvider( id );
QgsProcessingToolboxModelNode *node = index2node( index );
if ( !node )
return;

beginRemoveRows( QModelIndex(), index.row(), index.row() );
delete mRootNode->takeChild( node );
endRemoveRows();

repopulateRecentAlgorithms();
}
// native providers use top level groups - so we can't
// work out what to remove. Just rebuild the whole model instead.
rebuild();
}

QgsProcessingToolboxModelNode *QgsProcessingToolboxModel::index2node( const QModelIndex &index ) const
@@ -651,7 +633,7 @@ QModelIndex QgsProcessingToolboxModel::indexOfParentTreeNode( QgsProcessingToolb
QgsProcessingToolboxProxyModel::QgsProcessingToolboxProxyModel( QObject *parent, QgsProcessingRegistry *registry,
QgsProcessingRecentAlgorithmLog *recentLog )
: QSortFilterProxyModel( parent )
, mModel( new QgsProcessingToolboxModel( parent, registry, recentLog ) )
, mModel( new QgsProcessingToolboxModel( this, registry, recentLog ) )
{
setSourceModel( mModel );
setDynamicSortFilter( true );

0 comments on commit 7933c85

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