Skip to content

Commit

Permalink
[Plugins] disable plugins which crash on load
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Feb 15, 2016
1 parent 8af571a commit fa40e78
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
2 changes: 2 additions & 0 deletions python/pyplugin_installer/installer.py
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion python/pyplugin_installer/installer_data.py
Expand Up @@ -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:
Expand Down
33 changes: 23 additions & 10 deletions src/app/qgspluginregistry.cpp
Expand Up @@ -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 ) );
}
}
}
Expand All @@ -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() )
Expand All @@ -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
Expand Down

0 comments on commit fa40e78

Please sign in to comment.