From 99f7fb6fcd84db0c8c7ea209ec49dbf087da4812 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 28 Jun 2016 02:58:06 +0200 Subject: [PATCH] Show error instead of crash when using method or property before C++ object is constructed --- doc/ReleaseNotes | 1 + dtool/src/interrogatedb/py_panda.cxx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index ec8621329d..3a02861ab3 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -10,6 +10,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix loading old models with MovingPart * Improve performance of CPU vertex animation somewhat * Show framebuffer properties when fbprop request fails +* Show error instead of crash on use of object before __init__ * Fix hang on exit when using Python task on threaded task chain * Fix inability to get RGBA renderbuffer in certain cases * Work around GLSL issue with #pragma and certain Intel drivers diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 02666e0fb0..ed81825bd8 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -70,7 +70,7 @@ void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *c // wrong type, raises an AttributeError. //////////////////////////////////////////////////////////////////// bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer) { - if (self == NULL || !DtoolCanThisBeAPandaInstance(self)) { + if (self == NULL || !DtoolCanThisBeAPandaInstance(self) || ((Dtool_PyInstDef *)self)->_ptr_to_object == NULL) { Dtool_Raise_TypeError("C++ object is not yet constructed, or already destructed."); return false; } @@ -93,7 +93,7 @@ bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, void **answer, const char *method_name) { - if (self == NULL || !DtoolCanThisBeAPandaInstance(self)) { + if (self == NULL || !DtoolCanThisBeAPandaInstance(self) || ((Dtool_PyInstDef *)self)->_ptr_to_object == NULL) { Dtool_Raise_TypeError("C++ object is not yet constructed, or already destructed."); return false; }