diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 33d54fd3246..97ca03f48f4 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -7654,6 +7654,12 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr) pyrna = (BPy_StructRNA *)PyObject_New(BPy_StructRNA, &pyrna_struct_Type); #endif +#ifdef USE_PYRNA_STRUCT_REFERENCE + /* #PyType_GenericAlloc will have set tracking. + * We only want tracking when `StructRNA.reference` has been set. */ + PyObject_GC_UnTrack(pyrna); +#endif + #ifdef USE_WEAKREFS if (pyrna != nullptr) { pyrna->in_weakreflist = nullptr;