bugfix: segfault in Grid.at() due to internal types not exported to module
After #184/#189 made GridPoint and GridPointState internal-only types, code using PyObject_GetAttrString(mcrf_module, "GridPoint") would get NULL and crash when dereferencing. Fixed by using the type directly via &mcrfpydef::PyUIGridPointType instead of looking it up in the module. Affected functions: - UIGrid::py_at() - UIGridPointState::get_point() - UIEntity::at() - UIGridPointState_to_PyObject() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f9b6cdef1c
commit
a4c2c04343
3 changed files with 8 additions and 16 deletions
|
|
@ -201,12 +201,9 @@ PyObject* UIGridPointState::get_point(PyUIGridPointStateObject* self, void* clos
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// Return the GridPoint at this position
|
||||
auto type = (PyTypeObject*)PyObject_GetAttrString(McRFPy_API::mcrf_module, "GridPoint");
|
||||
if (!type) return NULL;
|
||||
|
||||
// Return the GridPoint at this position (use type directly since it's internal-only)
|
||||
auto type = &mcrfpydef::PyUIGridPointType;
|
||||
auto obj = (PyUIGridPointObject*)type->tp_alloc(type, 0);
|
||||
Py_DECREF(type);
|
||||
if (!obj) return NULL;
|
||||
|
||||
// Get the GridPoint from the grid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue