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.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
648b2cb46b
commit
f61438d7d9
9 changed files with 69 additions and 33 deletions
|
@ -2738,8 +2738,17 @@ CPrimitiveContext::CPrimitiveContext():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool LIGORegistered = false;
|
||||||
|
|
||||||
|
|
||||||
void Register ()
|
void Register ()
|
||||||
{
|
{
|
||||||
|
if( LIGORegistered )
|
||||||
|
{
|
||||||
|
nlinfo( "LIGO classes have already been registered." );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NLMISC_REGISTER_CLASS(CPropertyString);
|
NLMISC_REGISTER_CLASS(CPropertyString);
|
||||||
NLMISC_REGISTER_CLASS(CPropertyStringArray);
|
NLMISC_REGISTER_CLASS(CPropertyStringArray);
|
||||||
NLMISC_REGISTER_CLASS(CPropertyColor);
|
NLMISC_REGISTER_CLASS(CPropertyColor);
|
||||||
|
@ -2748,6 +2757,8 @@ void Register ()
|
||||||
NLMISC_REGISTER_CLASS(CPrimPath);
|
NLMISC_REGISTER_CLASS(CPrimPath);
|
||||||
NLMISC_REGISTER_CLASS(CPrimZone);
|
NLMISC_REGISTER_CLASS(CPrimZone);
|
||||||
NLMISC_REGISTER_CLASS(CPrimAlias);
|
NLMISC_REGISTER_CLASS(CPrimAlias);
|
||||||
|
|
||||||
|
LIGORegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -143,6 +143,8 @@ 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);
|
||||||
|
context->onActivated();
|
||||||
|
|
||||||
Q_EMIT currentContextChanged(context);
|
Q_EMIT currentContextChanged(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ public:
|
||||||
virtual void newDocument(){}
|
virtual void newDocument(){}
|
||||||
|
|
||||||
virtual void close(){}
|
virtual void close(){}
|
||||||
|
|
||||||
|
virtual void onActivated(){}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
@ -484,6 +484,11 @@ void MissionCompilerMainWindow::saveConfig() {
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MissionCompilerMainWindow::onActivated()
|
||||||
|
{
|
||||||
|
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
void MissionCompilerMainWindow::handleChangedSettings()
|
void MissionCompilerMainWindow::handleChangedSettings()
|
||||||
{
|
{
|
||||||
QStringList servers;
|
QStringList servers;
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
QUndoStack *getUndoStack() { return m_undoStack; }
|
QUndoStack *getUndoStack() { return m_undoStack; }
|
||||||
|
|
||||||
|
void onActivated();
|
||||||
|
|
||||||
typedef std::map<std::string, CMission> TMissionContainer;
|
typedef std::map<std::string, CMission> TMissionContainer;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
|
@ -83,6 +83,12 @@ public:
|
||||||
virtual void open() {}
|
virtual void open() {}
|
||||||
|
|
||||||
|
|
||||||
|
void onActivated()
|
||||||
|
{
|
||||||
|
m_missionCompilerMainWindow->onActivated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MissionCompilerMainWindow *m_missionCompilerMainWindow;
|
MissionCompilerMainWindow *m_missionCompilerMainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -54,36 +54,6 @@ bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManage
|
||||||
|
|
||||||
WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this);
|
WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this);
|
||||||
addAutoReleasedObject(weSettings);
|
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));
|
addAutoReleasedObject(new WorldEditorContext(this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +87,34 @@ WorldEditorContext::WorldEditorContext(QObject *parent)
|
||||||
m_worldEditorWindow(0)
|
m_worldEditorWindow(0)
|
||||||
{
|
{
|
||||||
m_worldEditorWindow = new WorldEditorWindow();
|
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()
|
QUndoStack *WorldEditorContext::undoStack()
|
||||||
|
@ -124,6 +122,11 @@ QUndoStack *WorldEditorContext::undoStack()
|
||||||
return m_worldEditorWindow->undoStack();
|
return m_worldEditorWindow->undoStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldEditorContext::onActivated()
|
||||||
|
{
|
||||||
|
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
void WorldEditorContext::open()
|
void WorldEditorContext::open()
|
||||||
{
|
{
|
||||||
m_worldEditorWindow->open();
|
m_worldEditorWindow->open();
|
||||||
|
|
|
@ -59,7 +59,6 @@ protected:
|
||||||
NLMISC::CLibraryContext *m_libContext;
|
NLMISC::CLibraryContext *m_libContext;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NLLIGO::CLigoConfig m_ligoConfig;
|
|
||||||
ExtensionSystem::IPluginManager *m_plugMan;
|
ExtensionSystem::IPluginManager *m_plugMan;
|
||||||
QList<QObject *> m_autoReleaseObjects;
|
QList<QObject *> m_autoReleaseObjects;
|
||||||
};
|
};
|
||||||
|
@ -88,9 +87,14 @@ public:
|
||||||
|
|
||||||
virtual QUndoStack *undoStack();
|
virtual QUndoStack *undoStack();
|
||||||
|
|
||||||
|
void onActivated();
|
||||||
|
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
|
|
||||||
WorldEditorWindow *m_worldEditorWindow;
|
WorldEditorWindow *m_worldEditorWindow;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NLLIGO::CLigoConfig m_ligoConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace WorldEditor
|
} // namespace WorldEditor
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
~WorldEditorWindow();
|
~WorldEditorWindow();
|
||||||
|
|
||||||
QUndoStack *undoStack() const;
|
QUndoStack *undoStack() const;
|
||||||
|
void onActivated();
|
||||||
void maybeSave();
|
void maybeSave();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
Loading…
Reference in a new issue