mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Plugin loading, with issues..
--HG-- branch : gsoc2014-dfighter
This commit is contained in:
parent
c45b6a17f4
commit
f060adbed7
5 changed files with 72 additions and 17 deletions
|
@ -114,8 +114,62 @@ void PluginManager::loadPlugins()
|
||||||
Q_EMIT pluginsChanged();
|
Q_EMIT pluginsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PluginManager::loadPluginSpec( const char *plugin )
|
||||||
|
{
|
||||||
|
nlinfo( "Loading plugin spec %s", plugin );
|
||||||
|
|
||||||
|
PluginSpec *spec = new PluginSpec;
|
||||||
|
spec->m_pluginManager = this;
|
||||||
|
if( !spec->setSpecFileName( plugin ) )
|
||||||
|
{
|
||||||
|
nlinfo( "Error loading plugin spec %s", plugin );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pluginSpecs.append( spec );
|
||||||
|
m_ipluginSpecs.append( spec );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool PluginManager::loadPlugin( const char *plugin )
|
bool PluginManager::loadPlugin( const char *plugin )
|
||||||
{
|
{
|
||||||
|
if( !loadPluginSpec( plugin ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ExtensionSystem::PluginSpec *spec = m_pluginSpecs.last();
|
||||||
|
|
||||||
|
if( !spec->resolveDependencies( m_pluginSpecs ) )
|
||||||
|
{
|
||||||
|
nlinfo( "Error resolving dependencies for plugin spec %s", plugin );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !spec->loadLibrary() )
|
||||||
|
{
|
||||||
|
nlinfo( "Error loading plugin %s", spec->fileName().toUtf8().data() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !spec->initializePlugin() )
|
||||||
|
{
|
||||||
|
nlinfo( "Error initializing plugin %s", spec->fileName().toUtf8().data() );
|
||||||
|
spec->kill();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !spec->initializeExtensions() )
|
||||||
|
{
|
||||||
|
nlinfo( "Error starting plugin %s", spec->fileName().toUtf8().data() );
|
||||||
|
spec->stop();
|
||||||
|
spec->kill();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlinfo( "Loaded plugin %s ( %s )", spec->name().data(), spec->fileName().toUtf8().data() );
|
||||||
|
|
||||||
|
Q_EMIT pluginsChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,11 +316,7 @@ void PluginManager::readPluginPaths()
|
||||||
|
|
||||||
Q_FOREACH (const QString &pluginFile, pluginsList)
|
Q_FOREACH (const QString &pluginFile, pluginsList)
|
||||||
{
|
{
|
||||||
PluginSpec *spec = new PluginSpec;
|
loadPluginSpec( pluginFile.toUtf8().data() );
|
||||||
spec->m_pluginManager = this;
|
|
||||||
spec->setSpecFileName(pluginFile);
|
|
||||||
m_pluginSpecs.append(spec);
|
|
||||||
m_ipluginSpecs.append(spec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT pluginsChanged();
|
Q_EMIT pluginsChanged();
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
virtual QList<IPluginSpec *> plugins() const;
|
virtual QList<IPluginSpec *> plugins() const;
|
||||||
QList<PluginSpec *> loadQueue();
|
QList<PluginSpec *> loadQueue();
|
||||||
|
|
||||||
|
bool loadPluginSpec( const char *plugin );
|
||||||
bool loadPlugin( const char *plugin );
|
bool loadPlugin( const char *plugin );
|
||||||
bool unloadPlugin( ExtensionSystem::IPluginSpec *plugin );
|
bool unloadPlugin( ExtensionSystem::IPluginSpec *plugin );
|
||||||
void removePlugin( ExtensionSystem::IPluginSpec *plugin );
|
void removePlugin( ExtensionSystem::IPluginSpec *plugin );
|
||||||
|
|
|
@ -36,13 +36,11 @@ struct ContextManagerPrivate
|
||||||
Core::MainWindow *m_mainWindow;
|
Core::MainWindow *m_mainWindow;
|
||||||
QTabWidget *m_tabWidget;
|
QTabWidget *m_tabWidget;
|
||||||
QVector<IContext *> m_contexts;
|
QVector<IContext *> m_contexts;
|
||||||
int m_oldCurrent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||||
: m_mainWindow(mainWindow),
|
: m_mainWindow(mainWindow),
|
||||||
m_tabWidget(tabWidget),
|
m_tabWidget(tabWidget)
|
||||||
m_oldCurrent(-1)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,11 +143,7 @@ void ContextManager::currentTabChanged(int index)
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
IContext *context = d->m_contexts.at(index);
|
IContext *context = d->m_contexts.at(index);
|
||||||
IContext *oldContext = 0;
|
Q_EMIT currentContextChanged(context);
|
||||||
if (d->m_oldCurrent >= 0)
|
|
||||||
oldContext = d->m_contexts.at(d->m_oldCurrent);
|
|
||||||
d->m_oldCurrent = index;
|
|
||||||
Q_EMIT currentContextChanged(context, oldContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ public:
|
||||||
void unregisterUndoStack(QUndoStack *stack);
|
void unregisterUndoStack(QUndoStack *stack);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
// the default argument '=0' is important for connects without the oldContext argument.
|
void currentContextChanged(Core::IContext *context);
|
||||||
void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void activateContext(const QString &id);
|
void activateContext(const QString &id);
|
||||||
|
|
|
@ -155,7 +155,18 @@ void PluginView::onLoadClicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_pluginManager->loadPlugin( f.toAscii().data() );
|
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||||
|
bool success = m_pluginManager->loadPlugin( f.toAscii().data() );
|
||||||
|
QApplication::setOverrideCursor( Qt::ArrowCursor );
|
||||||
|
|
||||||
|
if( !success )
|
||||||
|
{
|
||||||
|
QMessageBox::warning( this,
|
||||||
|
tr( "Loading plugin" ),
|
||||||
|
tr( "Error loading plugin!" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace Core */
|
|
||||||
|
} /* namespace Core */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue