clear dict when invalidating Py object to fix possible cyclic references

This commit is contained in:
wmayer
2018-08-25 21:49:57 +02:00
parent 5eaf2e6387
commit f8f4cd76cc
2 changed files with 9 additions and 0 deletions

View File

@@ -426,3 +426,10 @@ void PyObjectBase::untrackAttribute(const char* attr)
PyDict_DelItemString(attrDict, attr);
}
}
void PyObjectBase::clearAttributes()
{
if (attrDict) {
PyDict_Clear(attrDict);
}
}

View File

@@ -286,6 +286,7 @@ public:
void setInvalid() {
// first bit is not set, i.e. invalid
StatusBits.reset(Valid);
clearAttributes();
_pcTwinPointer = 0;
}
@@ -320,6 +321,7 @@ private:
PyObject* getTrackedAttribute(const char* attr);
void trackAttribute(const char* attr, PyObject* obj);
void untrackAttribute(const char* attr);
void clearAttributes();
protected:
std::bitset<32> StatusBits;