1
0
forked from 0ad/0ad

Fixes broken selections in saved games (CmpSelectable needed to call Init on deserialization).

Adds function name to log output when serializer fails on functions, to
aid in debugging.

This was SVN commit r11199.
This commit is contained in:
historic_bruno 2012-02-28 22:12:30 +00:00
parent c169898a18
commit 366cd7f15a
2 changed files with 20 additions and 2 deletions

View File

@ -89,8 +89,10 @@ public:
// reconstructed by the GUI soon enough, I think)
}
virtual void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& UNUSED(deserialize))
virtual void Deserialize(const CParamNode& paramNode, IDeserializer& UNUSED(deserialize))
{
// Need to call Init to reload the template properties
Init(paramNode);
}
virtual void HandleMessage(const CMessage& msg, bool UNUSED(global))

View File

@ -132,7 +132,23 @@ void CBinarySerializerScriptImpl::HandleScriptVal(jsval val)
}
case JSTYPE_FUNCTION:
{
LOGERROR(L"Cannot serialise JS objects of type 'function'");
// We can't serialise functions, but we can at least name the offender (hopefully)
const jschar* funcname = NULL;
size_t length = 0;
JSFunction* func = JS_ValueToFunction(cx, val);
if (func)
{
JSString* string = JS_GetFunctionId(func);
if (string)
{
funcname = JS_GetStringCharsAndLength(cx, string, &length);
}
}
if (!funcname || !length)
funcname = L"(unnamed)";
LOGERROR(L"Cannot serialise JS objects of type 'function': %ls", funcname);
throw PSERROR_Serialize_InvalidScriptValue();
}
case JSTYPE_STRING: