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:
John McCardle 2026-01-06 04:38:56 -05:00
commit a4c2c04343
3 changed files with 8 additions and 16 deletions

View file

@ -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