Skip to content

Commit fa40e78

Browse files
committedFeb 15, 2016
[Plugins] disable plugins which crash on load
1 parent 8af571a commit fa40e78

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed
 

‎python/pyplugin_installer/installer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ def __init__(self):
9191
updateAvailablePlugins()
9292
settings = QSettings()
9393
if settings.value("/PythonPlugins/" + key, False, type=bool):
94+
settings.setValue("/PythonPlugins/watchDog/" + key, True)
9495
loadPlugin(key)
9596
startPlugin(key)
97+
settings.remove("/PythonPlugins/watchDog/" + key)
9698

9799
# ----------------------------------------- #
98100
def fetchAvailablePlugins(self, reloadMode):

‎python/pyplugin_installer/installer_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ def getAllInstalled(self, testLoad=True):
696696
# readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
697697
readOnly = isTheSystemDir # Assume only the system plugins are not writable.
698698
# only test those not yet loaded. Loaded plugins already proved they're o.k.
699-
testLoadThis = testLoad and key not in qgis.utils.plugins
699+
failedToLoad = settings.value("/PythonPlugins/watchDog/" + key) is not None
700+
testLoadThis = testLoad and key not in qgis.utils.plugins and not failedToLoad
700701
plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
701702
self.localCache[key] = plugin
702703
if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1:

‎src/app/qgspluginregistry.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
469469
// check if the plugin was active on last session
470470

471471
QString baseName = QFileInfo( myFullPath ).baseName();
472+
if ( mySettings.value( QString( "/Plugins/watchDog/%1" ).arg( baseName ) ).isValid() )
473+
{
474+
mQgisInterface->messageBar()->pushWarning( QObject::tr( "Plugin %1" ).arg( baseName ), QObject::tr( "The plugin will be disabled because it crashed QGIS during last startup. Please report an issue and re-enable the plugin when the problem has been solved." ) );
475+
mySettings.setValue( "/Plugins/" + baseName, false );
476+
}
472477
if ( mySettings.value( "/Plugins/" + baseName ).toBool() )
473478
{
479+
mySettings.setValue( QString( "/Plugins/watchDog/%1" ).arg( baseName ), true );
474480
loadCppPlugin( myFullPath );
481+
mySettings.remove( QString( "/Plugins/watchDog/%1" ).arg( baseName ) );
475482
}
476483
}
477484
}
@@ -490,18 +497,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
490497
corePlugins << "MetaSearch";
491498

492499
// make the required core plugins enabled by default:
493-
for ( int i = 0; i < corePlugins.size(); i++ )
500+
Q_FOREACH ( const QString& corePlugin, corePlugins )
494501
{
495-
if ( !mySettings.contains( "/PythonPlugins/" + corePlugins[i] ) )
502+
if ( !mySettings.contains( "/PythonPlugins/" + corePlugin ) )
496503
{
497-
mySettings.setValue( "/PythonPlugins/" + corePlugins[i], true );
504+
mySettings.setValue( "/PythonPlugins/" + corePlugin, true );
498505
}
499506
}
500507

501-
for ( int i = 0; i < pluginList.size(); i++ )
508+
Q_FOREACH ( const QString& packageName, pluginList )
502509
{
503-
QString packageName = pluginList[i];
504-
505510
// TODO: apply better solution for #5879
506511
// start - temporary fix for issue #5879
507512
if ( QgsApplication::isRunningFromBuildDir() )
@@ -517,14 +522,22 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
517522
}
518523
// end - temporary fix for issue #5879, more below
519524

520-
if ( checkPythonPlugin( packageName ) )
521-
{
522-
// check if the plugin was active on last session
523525

524-
if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() )
526+
if ( mySettings.value( "/PythonPlugins/watchDog/" + packageName ).isValid() )
527+
{
528+
mQgisInterface->messageBar()->pushWarning( "Plugin " + packageName, "The plugin will be disabled because it crashed QGIS during last startup. Please report an issue and re-enable the plugin when the problem has been solved." );
529+
mySettings.setValue( "/PythonPlugins/" + packageName, false );
530+
}
531+
// check if the plugin was active on last session
532+
if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() )
533+
{
534+
mySettings.setValue( "/PythonPlugins/watchDog/" + packageName, true );
535+
if ( checkPythonPlugin( packageName ) )
525536
{
526537
loadPythonPlugin( packageName );
527538
}
539+
mySettings.remove( "/PythonPlugins/watchDog/" + packageName );
540+
528541
}
529542
}
530543
// start - temporary fix for issue #5879, more above

0 commit comments

Comments
 (0)
Please sign in to comment.