Skip to content

Commit 99f7fb6

Browse files
committed
Show error instead of crash when using method or property before C++ object is constructed
1 parent 7eb7ffb commit 99f7fb6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/ReleaseNotes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This issue fixes several bugs that were still found in 1.9.2.
1010
* Fix loading old models with MovingPart<LMatrix4f>
1111
* Improve performance of CPU vertex animation somewhat
1212
* Show framebuffer properties when fbprop request fails
13+
* Show error instead of crash on use of object before __init__
1314
* Fix hang on exit when using Python task on threaded task chain
1415
* Fix inability to get RGBA renderbuffer in certain cases
1516
* Work around GLSL issue with #pragma and certain Intel drivers

dtool/src/interrogatedb/py_panda.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *c
7070
// wrong type, raises an AttributeError.
7171
////////////////////////////////////////////////////////////////////
7272
bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer) {
73-
if (self == NULL || !DtoolCanThisBeAPandaInstance(self)) {
73+
if (self == NULL || !DtoolCanThisBeAPandaInstance(self) || ((Dtool_PyInstDef *)self)->_ptr_to_object == NULL) {
7474
Dtool_Raise_TypeError("C++ object is not yet constructed, or already destructed.");
7575
return false;
7676
}
@@ -93,7 +93,7 @@ bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef
9393
bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef,
9494
void **answer, const char *method_name) {
9595

96-
if (self == NULL || !DtoolCanThisBeAPandaInstance(self)) {
96+
if (self == NULL || !DtoolCanThisBeAPandaInstance(self) || ((Dtool_PyInstDef *)self)->_ptr_to_object == NULL) {
9797
Dtool_Raise_TypeError("C++ object is not yet constructed, or already destructed.");
9898
return false;
9999
}

0 commit comments

Comments
 (0)