Skip to content

Commit

Permalink
Fix ShapeBase.group setter to only migrate batch when batch is not No…
Browse files Browse the repository at this point in the history
…ne (#1090)

* Only migrate batch in ShapeBase.group setter when batch is not None

* Update ShapeBase.group docstring
  • Loading branch information
pushfoo committed Apr 16, 2024
1 parent 5ee6e3a commit 557cf91
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pyglet/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,11 @@ def visible(self, value: bool) -> None:
def group(self) -> Group:
"""Get/set the shape's :class:`Group`.
.. warning:: This breaks when :py:attr:`.batch` is ``None``!
You can migrate a shape from one group to another by setting
this property, but it can be an expensive (slow) operation. This
will also trigger a batch migration.
this property. Note that it can be an expensive (slow) operation.
If :py:attr:`.batch` isn't ``None``, setting this property will
also trigger a batch migration.
"""
return self._group.parent

Expand All @@ -615,8 +615,11 @@ def group(self, group: Group) -> None:
self._group.blend_dest,
self._group.program,
group)
self._batch.migrate(self._vertex_list, self._draw_mode, self._group,
self._batch)
if self._batch:
self._batch.migrate(self._vertex_list,
self._draw_mode,
self._group,
self._batch)

@property
def batch(self) -> Batch | None:
Expand Down

0 comments on commit 557cf91

Please sign in to comment.