Skip to content
Permalink
Browse files

[Plugins] disable plugins which crash on load

  • Loading branch information
m-kuhn committed Feb 14, 2016
1 parent 8af571a commit fa40e78f60838c6d663363e26146b11088e348c0
@@ -91,8 +91,10 @@ def __init__(self):
updateAvailablePlugins()
settings = QSettings()
if settings.value("/PythonPlugins/" + key, False, type=bool):
settings.setValue("/PythonPlugins/watchDog/" + key, True)
loadPlugin(key)
startPlugin(key)
settings.remove("/PythonPlugins/watchDog/" + key)

# ----------------------------------------- #
def fetchAvailablePlugins(self, reloadMode):
@@ -696,7 +696,8 @@ def getAllInstalled(self, testLoad=True):
# readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
readOnly = isTheSystemDir # Assume only the system plugins are not writable.
# 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)
self.localCache[key] = plugin
if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1:
@@ -469,9 +469,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
// check if the plugin was active on last session

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() )
{
mySettings.setValue( QString( "/Plugins/watchDog/%1" ).arg( baseName ), true );
loadCppPlugin( myFullPath );
mySettings.remove( QString( "/Plugins/watchDog/%1" ).arg( baseName ) );
}
}
}
@@ -490,18 +497,16 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
corePlugins << "MetaSearch";

// 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
// start - temporary fix for issue #5879
if ( QgsApplication::isRunningFromBuildDir() )
@@ -517,14 +522,22 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
}
// 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 );
}
mySettings.remove( "/PythonPlugins/watchDog/" + packageName );

}
}
// start - temporary fix for issue #5879, more above

0 comments on commit fa40e78

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