mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 05:36:13 +00:00
Plugin loading, with issues..
This commit is contained in:
parent
1a75899790
commit
9aa58daa83
5 changed files with 72 additions and 17 deletions
|
@ -114,8 +114,62 @@ void PluginManager::loadPlugins()
|
|||
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 )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -262,11 +316,7 @@ void PluginManager::readPluginPaths()
|
|||
|
||||
Q_FOREACH (const QString &pluginFile, pluginsList)
|
||||
{
|
||||
PluginSpec *spec = new PluginSpec;
|
||||
spec->m_pluginManager = this;
|
||||
spec->setSpecFileName(pluginFile);
|
||||
m_pluginSpecs.append(spec);
|
||||
m_ipluginSpecs.append(spec);
|
||||
loadPluginSpec( pluginFile.toUtf8().data() );
|
||||
}
|
||||
|
||||
Q_EMIT pluginsChanged();
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
virtual QList<IPluginSpec *> plugins() const;
|
||||
QList<PluginSpec *> loadQueue();
|
||||
|
||||
bool loadPluginSpec( const char *plugin );
|
||||
bool loadPlugin( const char *plugin );
|
||||
bool unloadPlugin( ExtensionSystem::IPluginSpec *plugin );
|
||||
void removePlugin( ExtensionSystem::IPluginSpec *plugin );
|
||||
|
|
|
@ -36,13 +36,11 @@ struct ContextManagerPrivate
|
|||
Core::MainWindow *m_mainWindow;
|
||||
QTabWidget *m_tabWidget;
|
||||
QVector<IContext *> m_contexts;
|
||||
int m_oldCurrent;
|
||||
};
|
||||
|
||||
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||
: m_mainWindow(mainWindow),
|
||||
m_tabWidget(tabWidget),
|
||||
m_oldCurrent(-1)
|
||||
m_tabWidget(tabWidget)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -145,11 +143,7 @@ void ContextManager::currentTabChanged(int index)
|
|||
if (index >= 0)
|
||||
{
|
||||
IContext *context = d->m_contexts.at(index);
|
||||
IContext *oldContext = 0;
|
||||
if (d->m_oldCurrent >= 0)
|
||||
oldContext = d->m_contexts.at(d->m_oldCurrent);
|
||||
d->m_oldCurrent = index;
|
||||
Q_EMIT currentContextChanged(context, oldContext);
|
||||
Q_EMIT currentContextChanged(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,7 @@ public:
|
|||
void unregisterUndoStack(QUndoStack *stack);
|
||||
|
||||
Q_SIGNALS:
|
||||
// the default argument '=0' is important for connects without the oldContext argument.
|
||||
void currentContextChanged(Core::IContext *context, Core::IContext *oldContext = 0);
|
||||
void currentContextChanged(Core::IContext *context);
|
||||
|
||||
public Q_SLOTS:
|
||||
void activateContext(const QString &id);
|
||||
|
|
|
@ -155,7 +155,18 @@ void PluginView::onLoadClicked()
|
|||
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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue