0.1.26
Loading...
Searching...
No Matches
pyhelios.Context Namespace Reference

Classes

class  Context
 Central simulation environment for PyHelios that manages 3D primitives and their data. More...
 
class  PrimitiveInfo
 Physical properties and geometry information for a primitive. More...
 

Functions

None check_context_alive ('Context' context, str owner_name)
 Raise if context's native Context has already been destroyed.
 

Function Documentation

◆ check_context_alive()

None pyhelios.Context.check_context_alive ( 'Context' context,
str owner_name )

Raise if context's native Context has already been destroyed.

Plugin models pass context.getNativePtr() to a C++ constructor that stores the raw pointer for the lifetime of the model. Destroying the Context (via __exit__, __del__, or garbage collection) frees that memory without invalidating the model's copy, so any later call dereferences freed memory and segfaults.

Models must hold a Python reference to the owning Context (keeping it alive) and call this before every native call (turning an explicit close into an actionable error instead of a crash).

Parameters
contextThe Context the model was constructed from.
owner_nameClass name of the calling model, used in the message.
Exceptions
RuntimeErrorIf the Context has been destroyed.

Definition at line 6181 of file Context.py.