mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
harden Taml::write and Taml::compileCustomState
make sure we don't end up clearing the vector we're itterating by recursively chaining writes, and that we actually have a mCompiledNodes to itterate for compileCustomState
This commit is contained in:
parent
280866724d
commit
cf61a6b831
2 changed files with 18 additions and 3 deletions
|
|
@ -151,7 +151,8 @@ Taml::Taml() :
|
||||||
mAutoFormat(true),
|
mAutoFormat(true),
|
||||||
mProgenitorUpdate(true),
|
mProgenitorUpdate(true),
|
||||||
mAutoFormatBinaryExtension("baml"),
|
mAutoFormatBinaryExtension("baml"),
|
||||||
mAutoFormatJSONExtension("json")
|
mAutoFormatJSONExtension("json"),
|
||||||
|
mWriteLocked(false)
|
||||||
{
|
{
|
||||||
// Reset the file-path buffer.
|
// Reset the file-path buffer.
|
||||||
mFilePathBuffer[0] = 0;
|
mFilePathBuffer[0] = 0;
|
||||||
|
|
@ -215,6 +216,10 @@ bool Taml::write(SimObject* pSimObject, const char* pFilename)
|
||||||
AssertFatal(pSimObject != NULL, "Cannot write a NULL object.");
|
AssertFatal(pSimObject != NULL, "Cannot write a NULL object.");
|
||||||
AssertFatal(pFilename != NULL, "Cannot write to a NULL filename.");
|
AssertFatal(pFilename != NULL, "Cannot write to a NULL filename.");
|
||||||
|
|
||||||
|
if (mWriteLocked)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mWriteLocked = true;
|
||||||
// Expand the file-name into the file-path buffer unless we're a secure VFS
|
// Expand the file-name into the file-path buffer unless we're a secure VFS
|
||||||
#ifndef TORQUE_SECURE_VFS
|
#ifndef TORQUE_SECURE_VFS
|
||||||
Con::expandToolScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
Con::expandToolScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
||||||
|
|
@ -230,6 +235,7 @@ bool Taml::write(SimObject* pSimObject, const char* pFilename)
|
||||||
{
|
{
|
||||||
// No, so warn.
|
// No, so warn.
|
||||||
Con::warnf("Taml::writeFile() - Could not open filename '%s' for write.", mFilePathBuffer);
|
Con::warnf("Taml::writeFile() - Could not open filename '%s' for write.", mFilePathBuffer);
|
||||||
|
mWriteLocked = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +253,7 @@ bool Taml::write(SimObject* pSimObject, const char* pFilename)
|
||||||
|
|
||||||
// Reset the compilation.
|
// Reset the compilation.
|
||||||
resetCompilation();
|
resetCompilation();
|
||||||
|
mWriteLocked = false;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,6 +494,10 @@ void Taml::resetCompilation(void)
|
||||||
// Debug Profiling.
|
// Debug Profiling.
|
||||||
PROFILE_SCOPE(Taml_ResetCompilation);
|
PROFILE_SCOPE(Taml_ResetCompilation);
|
||||||
|
|
||||||
|
// make sure we don't reset while writing, as this can cause a crash
|
||||||
|
if (mWriteLocked)
|
||||||
|
return;
|
||||||
|
|
||||||
// Clear compiled nodes.
|
// Clear compiled nodes.
|
||||||
for (typeNodeVector::iterator itr = mCompiledNodes.begin(); itr != mCompiledNodes.end(); ++itr)
|
for (typeNodeVector::iterator itr = mCompiledNodes.begin(); itr != mCompiledNodes.end(); ++itr)
|
||||||
{
|
{
|
||||||
|
|
@ -926,8 +936,12 @@ void Taml::compileCustomState(TamlWriteNode* pTamlWriteNode)
|
||||||
tamlCustomWrite(pTamlWriteNode->mpTamlCallbacks, customNodes);
|
tamlCustomWrite(pTamlWriteNode->mpTamlCallbacks, customNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure we have compiled nodes to work with
|
||||||
|
if (mCompiledNodes.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// Fetch custom nodes.
|
// Fetch custom nodes.
|
||||||
const TamlCustomNodeVector& nodes = customNodes.getNodes();
|
TamlCustomNodeVector nodes = customNodes.getNodes();
|
||||||
|
|
||||||
// Finish if no custom nodes to process.
|
// Finish if no custom nodes to process.
|
||||||
if (nodes.size() == 0)
|
if (nodes.size() == 0)
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ private:
|
||||||
bool mAutoFormat;
|
bool mAutoFormat;
|
||||||
bool mWriteDefaults;
|
bool mWriteDefaults;
|
||||||
bool mProgenitorUpdate;
|
bool mProgenitorUpdate;
|
||||||
|
bool mWriteLocked;
|
||||||
char mFilePathBuffer[1024];
|
char mFilePathBuffer[1024];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue