Skip to content

Commit eda9cd3

Browse files
committed
[Plugin Manager] Better cope with broken plugins
1 parent b005f10 commit eda9cd3

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

python/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def startPlugin(packageName):
193193
global plugins, active_plugins, iface
194194

195195
if packageName in active_plugins: return False
196+
if packageName not in sys.modules: return False
196197

197198
package = sys.modules[packageName]
198199

src/app/pluginmanager/qgspluginmanager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,9 @@ void QgsPluginManager::pluginItemChanged( QStandardItem * item )
484484
QgsDebugMsg( " Loading plugin: " + id );
485485
loadPlugin( id );
486486
}
487-
else if ( ! item->checkState() && isPluginLoaded( id ) )
487+
else if ( ! item->checkState() )
488488
{
489+
// don't test if isPluginLoaded, to allow disable also plugins taht weren't successfully loaded
489490
QgsDebugMsg( " Unloading plugin: " + id );
490491
unloadPlugin( id );
491492
}

src/app/qgspluginregistry.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,12 @@ void QgsPluginRegistry::unloadPythonPlugin( QString packageName )
383383
if ( isLoaded( packageName ) )
384384
{
385385
mPythonUtils->unloadPlugin( packageName );
386-
// add to settings
387-
QSettings settings;
388-
settings.setValue( "/PythonPlugins/" + packageName, false );
389386
QgsDebugMsg( "Python plugin successfully unloaded: " + packageName );
390387
}
388+
389+
// disable the plugin no matter if successfully loaded or not
390+
QSettings settings;
391+
settings.setValue( "/PythonPlugins/" + packageName, false );
391392
}
392393

393394

0 commit comments

Comments
 (0)