mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
fix crash with threaded setPythonTag()
This commit is contained in:
parent
db54994233
commit
be85a6ada1
@ -4635,12 +4635,23 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void PandaNode::CData::
|
void PandaNode::CData::
|
||||||
inc_py_refs() {
|
inc_py_refs() {
|
||||||
PythonTagData::const_iterator ti;
|
if (!_python_tag_data.empty()) {
|
||||||
for (ti = _python_tag_data.begin();
|
#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
|
||||||
ti != _python_tag_data.end();
|
// This might happen at any time, so be sure the Python state is
|
||||||
++ti) {
|
// ready for it.
|
||||||
PyObject *value = (*ti).second;
|
PyGILState_STATE gstate;
|
||||||
Py_XINCREF(value);
|
gstate = PyGILState_Ensure();
|
||||||
|
#endif
|
||||||
|
PythonTagData::const_iterator ti;
|
||||||
|
for (ti = _python_tag_data.begin();
|
||||||
|
ti != _python_tag_data.end();
|
||||||
|
++ti) {
|
||||||
|
PyObject *value = (*ti).second;
|
||||||
|
Py_XINCREF(value);
|
||||||
|
}
|
||||||
|
#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
|
||||||
|
PyGILState_Release(gstate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
@ -4654,12 +4665,25 @@ inc_py_refs() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void PandaNode::CData::
|
void PandaNode::CData::
|
||||||
dec_py_refs() {
|
dec_py_refs() {
|
||||||
PythonTagData::const_iterator ti;
|
if (!_python_tag_data.empty()) {
|
||||||
for (ti = _python_tag_data.begin();
|
#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
|
||||||
ti != _python_tag_data.end();
|
// This might happen at any time, so be sure the Python state is
|
||||||
++ti) {
|
// ready for it.
|
||||||
PyObject *value = (*ti).second;
|
PyGILState_STATE gstate;
|
||||||
Py_XDECREF(value);
|
gstate = PyGILState_Ensure();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PythonTagData::const_iterator ti;
|
||||||
|
for (ti = _python_tag_data.begin();
|
||||||
|
ti != _python_tag_data.end();
|
||||||
|
++ti) {
|
||||||
|
PyObject *value = (*ti).second;
|
||||||
|
Py_XDECREF(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
|
||||||
|
PyGILState_Release(gstate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user