Don't deepcopy ShaderWrapper

This commit is contained in:
Grant Sanderson 2024-08-20 10:15:53 -05:00
parent b9645ad196
commit 0ac9ee1fbf
2 changed files with 12 additions and 2 deletions

View file

@ -652,9 +652,13 @@ class Mobject(object):
return self
def deepcopy(self) -> Self:
self.parents = []
result.target = None
result.saved_state = None
for submob in self.get_family():
submob._shaders_initialized = False
submob._data_has_changed = True
result = copy.deepcopy(self)
result._shaders_initialized = False
result._data_has_changed = True
return result
def copy(self, deep: bool = False) -> Self:

View file

@ -63,6 +63,12 @@ class ShaderWrapper(object):
self.init_vertex_objects()
self.refresh_id()
def __deepcopy__(self, memo):
# Don't allow deepcopies, e.g. if the mobject with this ShaderWrapper as an
# attribute gets copies. Returning None means the parent object with this ShaderWrapper
# as an attribute should smoothly handle this case.
return None
def init_program_code(self) -> None:
def get_code(name: str) -> str | None:
return get_shader_code_from_file(