浏览代码

fixes crash when callOnChildren

Anis and me managed to fix this: #1508
Alex Piola 9 年之前
父节点
当前提交
07cf85143b
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 4 2
      Engine/source/console/console.cpp
  2. 5 2
      Engine/source/console/simSet.cpp

+ 4 - 2
Engine/source/console/console.cpp

@@ -1252,7 +1252,7 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar
    if(object->getNamespace())
    {
       U32 ident = object->getId();
-      ConsoleValueRef oldIdent = argv[1];
+      ConsoleValueRef oldIdent(argv[1]);
 
       StringTableEntry funcName = StringTable->insert(argv[0]);
       Namespace::Entry *ent = object->getNamespace()->lookup(funcName);
@@ -1266,7 +1266,9 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar
       }
 
       // Twiddle %this argument
-      argv[1] = (S32)ident;
+      ConsoleValue func_ident;
+      func_ident.setIntValue((S32)ident);
+      argv[1] = ConsoleValueRef::fromValue(&func_ident);
 
       SimObject *save = gEvalState.thisObject;
       gEvalState.thisObject = object;

+ 5 - 2
Engine/source/console/simSet.cpp

@@ -233,8 +233,11 @@ void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef arg
 {
    // Prep the arguments for the console exec...
    // Make sure and leave args[1] empty.
-   ConsoleValueRef args[21];
-   args[0] = method.c_str();
+   ConsoleValueRef args[21] = { };
+   ConsoleValue name_method;
+   name_method.setStackStringValue(method.c_str());
+   args[0] = ConsoleValueRef::fromValue(&name_method);
+
    for (S32 i = 0; i < argc; i++)
       args[i + 2] = argv[i];