Migrate static PyTypeObject to inline, delete PyTypeCache workarounds
All 27 PyTypeObject declarations in namespace mcrfpydef headers changed from `static` to `inline` (C++17), ensuring a single global instance across translation units. This fixes the root cause of stale-type-pointer segfaults where only the McRFPy_API.cpp copy was PyType_Ready'd. Replaced ~20 PyTypeCache call sites and 2 PyRAII::PyTypeRef lookups with direct &mcrfpydef::Type references. Deleted PyTypeCache.h/.cpp, PyObjectUtils.h, and PyRAII.h (all were workarounds for the static bug). 228/228 tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6fdf7279ce
commit
bb72040396
37 changed files with 74 additions and 600 deletions
|
|
@ -5,7 +5,6 @@
|
|||
#include "MeshLayer.h" // For MeshVertex
|
||||
#include "../platform/GLContext.h"
|
||||
#include "../PyTexture.h"
|
||||
#include "../PyTypeCache.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
|
|
@ -355,8 +354,8 @@ int Billboard::init(PyObject* self, PyObject* args, PyObject* kwds) {
|
|||
|
||||
// Handle texture
|
||||
if (textureObj && textureObj != Py_None) {
|
||||
PyTypeObject* textureType = PyTypeCache::Texture();
|
||||
if (textureType && PyObject_IsInstance(textureObj, (PyObject*)textureType)) {
|
||||
PyTypeObject* textureType = &mcrfpydef::PyTextureType;
|
||||
if (PyObject_IsInstance(textureObj, (PyObject*)textureType)) {
|
||||
PyTextureObject* texPy = (PyTextureObject*)textureObj;
|
||||
if (texPy->data) {
|
||||
selfObj->data->setTexture(texPy->data);
|
||||
|
|
@ -443,12 +442,7 @@ int Billboard::set_texture(PyObject* self, PyObject* value, void* closure) {
|
|||
obj->data->setTexture(nullptr);
|
||||
return 0;
|
||||
}
|
||||
// Use PyTypeCache to get properly initialized type object
|
||||
PyTypeObject* textureType = PyTypeCache::Texture();
|
||||
if (!textureType) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Texture type not initialized");
|
||||
return -1;
|
||||
}
|
||||
PyTypeObject* textureType = &mcrfpydef::PyTextureType;
|
||||
if (PyObject_IsInstance(value, (PyObject*)textureType)) {
|
||||
PyTextureObject* texPy = (PyTextureObject*)value;
|
||||
if (texPy->data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue