mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
interrogate: fix crash when calling functions returning TypedWritable
This commit is contained in:
parent
1b1d80cd27
commit
b8bf8bd641
@ -745,11 +745,31 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr,
|
|||||||
<< " return Py_None;\n";
|
<< " return Py_None;\n";
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "} else {\n";
|
<< "} else {\n";
|
||||||
indent(out, indent_level)
|
// Special exception if we are returning TypedWritable, which might
|
||||||
<< " return DTool_CreatePyInstanceTyped((void *)" << return_expr
|
// actually be a derived class that inherits from ReferenceCount.
|
||||||
<< ", *Dtool_Ptr_" << make_safe_name(class_name) << ", "
|
if (!owns_memory && !is_const && class_name == "TypedWritable") {
|
||||||
<< owns_memory << ", " << is_const << ", "
|
indent(out, indent_level)
|
||||||
<< return_expr << "->as_typed_object()->get_type_index());\n";
|
<< " ReferenceCount *rc = " << return_expr << "->as_reference_count();\n";
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " bool is_refcount = (rc != (ReferenceCount *)NULL);\n";
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " if (is_refcount) {\n";
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " rc->ref();\n";
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " }\n";
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " return DTool_CreatePyInstanceTyped((void *)" << return_expr
|
||||||
|
<< ", *Dtool_Ptr_" << make_safe_name(class_name) << ", is_refcount, "
|
||||||
|
<< is_const << ", " << return_expr
|
||||||
|
<< "->get_type_index());\n";
|
||||||
|
} else {
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< " return DTool_CreatePyInstanceTyped((void *)" << return_expr
|
||||||
|
<< ", *Dtool_Ptr_" << make_safe_name(class_name) << ", "
|
||||||
|
<< owns_memory << ", " << is_const << ", "
|
||||||
|
<< return_expr << "->as_typed_object()->get_type_index());\n";
|
||||||
|
}
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user