Skip to content

Commit 7626494

Browse files
committed
Use Py_REFCNT instead of ob_refcnt in generated code
- ob_refcnt is not guaranteed to be there
1 parent 133d96c commit 7626494

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

generator/shellimplgenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
137137

138138
s << "if (_wrapper) {" << endl;
139139
s << " PYTHONQT_GIL_SCOPE" << endl;
140-
s << " if (((PyObject*)_wrapper)->ob_refcnt > 0) {" << endl;
140+
s << " if (Py_REFCNT((PyObject*)_wrapper) > 0) {" << endl;
141141
s << " static PyObject* name = PyString_FromString(\"" << fun->name() << "\");" << endl;
142142
s << " PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);" << endl;
143143
s << " if (obj) {" << endl;

0 commit comments

Comments
 (0)