mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 11:50:53 +00:00
Studio should no longer crash when multiple plugins that use LIGO are loaded. LIGO classes are now guarded against multiple registrations. If it's tried log messages are generated. Mission Compiler and World Editor will now apply their own LIGO configs when the user switches to their tab.
This commit is contained in:
parent
21c6daee96
commit
b98120ebb8
9 changed files with 69 additions and 33 deletions
|
@ -2738,8 +2738,17 @@ CPrimitiveContext::CPrimitiveContext():
|
|||
}
|
||||
|
||||
|
||||
static bool LIGORegistered = false;
|
||||
|
||||
|
||||
void Register ()
|
||||
{
|
||||
if( LIGORegistered )
|
||||
{
|
||||
nlinfo( "LIGO classes have already been registered." );
|
||||
return;
|
||||
}
|
||||
|
||||
NLMISC_REGISTER_CLASS(CPropertyString);
|
||||
NLMISC_REGISTER_CLASS(CPropertyStringArray);
|
||||
NLMISC_REGISTER_CLASS(CPropertyColor);
|
||||
|
@ -2748,6 +2757,8 @@ void Register ()
|
|||
NLMISC_REGISTER_CLASS(CPrimPath);
|
||||
NLMISC_REGISTER_CLASS(CPrimZone);
|
||||
NLMISC_REGISTER_CLASS(CPrimAlias);
|
||||
|
||||
LIGORegistered = true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
|
|
@ -143,6 +143,8 @@ void ContextManager::currentTabChanged(int index)
|
|||
if (index >= 0)
|
||||
{
|
||||
IContext *context = d->m_contexts.at(index);
|
||||
context->onActivated();
|
||||
|
||||
Q_EMIT currentContextChanged(context);
|
||||
}
|
||||
}
|
||||
|
@ -158,4 +160,4 @@ int ContextManager::indexOf(const QString &id) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
} /* namespace Core */
|
||||
} /* namespace Core */
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
virtual void newDocument(){}
|
||||
|
||||
virtual void close(){}
|
||||
|
||||
virtual void onActivated(){}
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -484,6 +484,11 @@ void MissionCompilerMainWindow::saveConfig() {
|
|||
settings->sync();
|
||||
}
|
||||
|
||||
void MissionCompilerMainWindow::onActivated()
|
||||
{
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||
}
|
||||
|
||||
void MissionCompilerMainWindow::handleChangedSettings()
|
||||
{
|
||||
QStringList servers;
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
void saveConfig();
|
||||
QUndoStack *getUndoStack() { return m_undoStack; }
|
||||
|
||||
void onActivated();
|
||||
|
||||
typedef std::map<std::string, CMission> TMissionContainer;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
|
|
@ -83,6 +83,12 @@ public:
|
|||
virtual void open() {}
|
||||
|
||||
|
||||
void onActivated()
|
||||
{
|
||||
m_missionCompilerMainWindow->onActivated();
|
||||
}
|
||||
|
||||
|
||||
MissionCompilerMainWindow *m_missionCompilerMainWindow;
|
||||
};
|
||||
|
||||
|
|
|
@ -54,36 +54,6 @@ bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManage
|
|||
|
||||
WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this);
|
||||
addAutoReleasedObject(weSettings);
|
||||
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||
m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat();
|
||||
m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat();
|
||||
m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt();
|
||||
QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString();
|
||||
settings->endGroup();
|
||||
try
|
||||
{
|
||||
// Search path of file world_editor_classes.xml
|
||||
std::string ligoPath = NLMISC::CPath::lookup(fileName.toUtf8().constData());
|
||||
// Init LIGO
|
||||
m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true);
|
||||
NLLIGO::Register();
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||
}
|
||||
catch (NLMISC::Exception &e)
|
||||
{
|
||||
*errorString = tr("(%1)").arg(e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset
|
||||
m_ligoConfig.resetPrimitiveConfiguration ();
|
||||
|
||||
// TODO: get file names! from settings
|
||||
m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true);
|
||||
|
||||
|
||||
addAutoReleasedObject(new WorldEditorContext(this));
|
||||
return true;
|
||||
}
|
||||
|
@ -117,6 +87,34 @@ WorldEditorContext::WorldEditorContext(QObject *parent)
|
|||
m_worldEditorWindow(0)
|
||||
{
|
||||
m_worldEditorWindow = new WorldEditorWindow();
|
||||
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||
m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat();
|
||||
m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat();
|
||||
m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt();
|
||||
QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString();
|
||||
settings->endGroup();
|
||||
try
|
||||
{
|
||||
// Search path of file world_editor_classes.xml
|
||||
std::string ligoPath = NLMISC::CPath::lookup(fileName.toUtf8().constData());
|
||||
// Init LIGO
|
||||
m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true);
|
||||
NLLIGO::Register();
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||
}
|
||||
catch (NLMISC::Exception &e)
|
||||
{
|
||||
nlinfo( "Error starting LIGO." );
|
||||
}
|
||||
|
||||
// Reset
|
||||
m_ligoConfig.resetPrimitiveConfiguration ();
|
||||
|
||||
// TODO: get file names! from settings
|
||||
m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true);
|
||||
|
||||
}
|
||||
|
||||
QUndoStack *WorldEditorContext::undoStack()
|
||||
|
@ -124,6 +122,11 @@ QUndoStack *WorldEditorContext::undoStack()
|
|||
return m_worldEditorWindow->undoStack();
|
||||
}
|
||||
|
||||
void WorldEditorContext::onActivated()
|
||||
{
|
||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||
}
|
||||
|
||||
void WorldEditorContext::open()
|
||||
{
|
||||
m_worldEditorWindow->open();
|
||||
|
@ -136,4 +139,4 @@ QWidget *WorldEditorContext::widget()
|
|||
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin)
|
||||
Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin)
|
||||
|
|
|
@ -59,7 +59,6 @@ protected:
|
|||
NLMISC::CLibraryContext *m_libContext;
|
||||
|
||||
private:
|
||||
NLLIGO::CLigoConfig m_ligoConfig;
|
||||
ExtensionSystem::IPluginManager *m_plugMan;
|
||||
QList<QObject *> m_autoReleaseObjects;
|
||||
};
|
||||
|
@ -88,9 +87,14 @@ public:
|
|||
|
||||
virtual QUndoStack *undoStack();
|
||||
|
||||
void onActivated();
|
||||
|
||||
virtual QWidget *widget();
|
||||
|
||||
WorldEditorWindow *m_worldEditorWindow;
|
||||
|
||||
private:
|
||||
NLLIGO::CLigoConfig m_ligoConfig;
|
||||
};
|
||||
|
||||
} // namespace WorldEditor
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
~WorldEditorWindow();
|
||||
|
||||
QUndoStack *undoStack() const;
|
||||
void onActivated();
|
||||
void maybeSave();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
Loading…
Reference in a new issue