Commit 5774a52c authored by Dmitry Risenberg's avatar Dmitry Risenberg
Browse files

Check that git is installed when loading Git Support plugin.

CCBUG: 257650.
parent b4e9df54
......@@ -199,6 +199,16 @@ void KDevelop::IPlugin::createActionsForMainWindow( Sublime::MainWindow* /*windo
{
}
bool KDevelop::IPlugin::hasError() const
{
return false;
}
QString KDevelop::IPlugin::errorDescription() const
{
return QString();
}
#include "iplugin.moc"
......@@ -213,6 +213,17 @@ public:
* @param actions Add your actions here. A new set of actions has to be created for each mainwindow.
*/
virtual void createActionsForMainWindow( Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions );
/**
* This function is necessary because there is no proper way to signal errors from plugin constructor.
* @returns True if the plugin has encountered an error, false otherwise.
*/
virtual bool hasError() const;
/**
* Description of the last encountered error, of an empty string if none.
*/
virtual QString errorDescription() const;
public Q_SLOTS:
/**
* Re-initialize the global icon loader
......
......@@ -48,6 +48,7 @@
#include <interfaces/iruncontroller.h>
#include "stashmanagerdialog.h"
#include <KMessageBox>
#include <KStandardDirs>
#include "gitjob.h"
K_PLUGIN_FACTORY(KDevGitFactory, registerPlugin<GitPlugin>(); )
......@@ -161,9 +162,16 @@ QDir urlDir(const KUrl::List& urls) { return urlDir(urls.first()); } //TODO: cou
GitPlugin::GitPlugin( QObject *parent, const QVariantList & )
: DistributedVersionControlPlugin(parent, KDevGitFactory::componentData()), m_oldVersion(false)
{
if (KStandardDirs::findExe("git").isEmpty()) {
m_hasError = true;
m_errorDescription = "git is not installed";
return;
}
KDEV_USE_EXTENSION_INTERFACE( KDevelop::IBasicVersionControl )
KDEV_USE_EXTENSION_INTERFACE( KDevelop::IDistributedVersionControl )
m_hasError = false;
core()->uiController()->addToolView(i18n("Git"), dvcsViewFactory());
setObjectName("Git");
......@@ -1175,3 +1183,13 @@ KDevelop::VcsLocationWidget* GitPlugin::vcsLocation(QWidget* parent) const
{
return new GitVcsLocationWidget(parent);
}
bool GitPlugin::hasError() const
{
return m_hasError;
}
QString GitPlugin::errorDescription() const
{
return m_errorDescription;
}
......@@ -138,6 +138,9 @@ public:
bool hasStashes(const QDir& repository);
bool hasModifications(const QDir& repository);
virtual bool hasError() const;
virtual QString errorDescription() const;
protected:
KUrl repositoryRoot(const KUrl& path);
......@@ -183,6 +186,9 @@ private:
/** Tells if it's older than 1.7.0 or not */
bool m_oldVersion;
bool m_hasError;
QString m_errorDescription;
};
#endif
......@@ -439,6 +439,13 @@ IPlugin *PluginController::loadPluginInternal( const QString &pluginId )
if ( plugin )
{
if ( plugin->hasError() ) {
KMessageBox::error(0, i18n("Plugin '%1' could not be loaded correctly and was disabled.\nReason: %2.", info.name(), plugin->errorDescription()));
info.setPluginEnabled(false);
info.save(Core::self()->activeSession()->config()->group(pluginControllerGrp));
unloadPlugin(pluginId);
return 0;
}
d->loadedPlugins.insert( info, plugin );
info.setPluginEnabled( true );
......
......@@ -79,6 +79,7 @@ void PluginPreferences::save()
selector->save();
KCModule::save();
Core::self()->pluginControllerInternal()->updateLoadedPlugins();
selector->load(); // Some plugins may have failed to load, they must be unchecked.
}
void PluginPreferences::load()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment