[Plugins] disable plugins which crash on load

This commit is contained in:
Matthias Kuhn 2016-02-14 16:28:50 +01:00
parent 8af571ae06
commit fa40e78f60
3 changed files with 27 additions and 11 deletions

View File

@ -91,8 +91,10 @@ class QgsPluginInstaller(QObject):
updateAvailablePlugins() updateAvailablePlugins()
settings = QSettings() settings = QSettings()
if settings.value("/PythonPlugins/" + key, False, type=bool): if settings.value("/PythonPlugins/" + key, False, type=bool):
settings.setValue("/PythonPlugins/watchDog/" + key, True)
loadPlugin(key) loadPlugin(key)
startPlugin(key) startPlugin(key)
settings.remove("/PythonPlugins/watchDog/" + key)
# ----------------------------------------- # # ----------------------------------------- #
def fetchAvailablePlugins(self, reloadMode): def fetchAvailablePlugins(self, reloadMode):

View File

@ -696,7 +696,8 @@ class Plugins(QObject):
# readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable. # readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
readOnly = isTheSystemDir # Assume only the system plugins are not writable. readOnly = isTheSystemDir # Assume only the system plugins are not writable.
# only test those not yet loaded. Loaded plugins already proved they're o.k. # only test those not yet loaded. Loaded plugins already proved they're o.k.
testLoadThis = testLoad and key not in qgis.utils.plugins failedToLoad = settings.value("/PythonPlugins/watchDog/" + key) is not None
testLoadThis = testLoad and key not in qgis.utils.plugins and not failedToLoad
plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis) plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
self.localCache[key] = plugin self.localCache[key] = plugin
if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1: if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1:

View File

@ -469,9 +469,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
// check if the plugin was active on last session // check if the plugin was active on last session
QString baseName = QFileInfo( myFullPath ).baseName(); QString baseName = QFileInfo( myFullPath ).baseName();
if ( mySettings.value( QString( "/Plugins/watchDog/%1" ).arg( baseName ) ).isValid() )
{
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." ) );
mySettings.setValue( "/Plugins/" + baseName, false );
}
if ( mySettings.value( "/Plugins/" + baseName ).toBool() ) if ( mySettings.value( "/Plugins/" + baseName ).toBool() )
{ {
mySettings.setValue( QString( "/Plugins/watchDog/%1" ).arg( baseName ), true );
loadCppPlugin( myFullPath ); loadCppPlugin( myFullPath );
mySettings.remove( QString( "/Plugins/watchDog/%1" ).arg( baseName ) );
} }
} }
} }
@ -490,18 +497,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
corePlugins << "MetaSearch"; corePlugins << "MetaSearch";
// make the required core plugins enabled by default: // make the required core plugins enabled by default:
for ( int i = 0; i < corePlugins.size(); i++ ) Q_FOREACH ( const QString& corePlugin, corePlugins )
{ {
if ( !mySettings.contains( "/PythonPlugins/" + corePlugins[i] ) ) if ( !mySettings.contains( "/PythonPlugins/" + corePlugin ) )
{ {
mySettings.setValue( "/PythonPlugins/" + corePlugins[i], true ); mySettings.setValue( "/PythonPlugins/" + corePlugin, true );
} }
} }
for ( int i = 0; i < pluginList.size(); i++ ) Q_FOREACH ( const QString& packageName, pluginList )
{ {
QString packageName = pluginList[i];
// TODO: apply better solution for #5879 // TODO: apply better solution for #5879
// start - temporary fix for issue #5879 // start - temporary fix for issue #5879
if ( QgsApplication::isRunningFromBuildDir() ) if ( QgsApplication::isRunningFromBuildDir() )
@ -517,14 +522,22 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
} }
// end - temporary fix for issue #5879, more below // end - temporary fix for issue #5879, more below
if ( checkPythonPlugin( packageName ) )
{
// check if the plugin was active on last session
if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() ) if ( mySettings.value( "/PythonPlugins/watchDog/" + packageName ).isValid() )
{
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." );
mySettings.setValue( "/PythonPlugins/" + packageName, false );
}
// check if the plugin was active on last session
if ( mySettings.value( "/PythonPlugins/" + packageName ).toBool() )
{
mySettings.setValue( "/PythonPlugins/watchDog/" + packageName, true );
if ( checkPythonPlugin( packageName ) )
{ {
loadPythonPlugin( packageName ); loadPythonPlugin( packageName );
} }
mySettings.remove( "/PythonPlugins/watchDog/" + packageName );
} }
} }
// start - temporary fix for issue #5879, more above // start - temporary fix for issue #5879, more above