File tree Expand file tree Collapse file tree
python/mujoco/experimental/studio Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030
3131from mujoco .experimental .dear_imgui import dear_imgui as imgui
3232
33+
3334@dataclasses .dataclass (frozen = True )
3435class ViewerAppInitEvent (messages .Event ):
3536 """Lifecycle event dispatched once when the ViewerApp is initialised.
@@ -418,12 +419,14 @@ def build_gui(self) -> None:
418419 imgui .End ()
419420 imgui .PopStyleVar (3 )
420421
421- @messages .handler (priority = messages .Priority .INTERNAL )
422+ # CRITICAL priority ensures the model is copied before any other handlers
423+ # are notified of the ModelEvent.
424+ @messages .handler (priority = messages .Priority .CRITICAL )
422425 def _on_model (self , event : messages .ModelEvent ) -> bool :
423426 self .model = copy .deepcopy (event .model )
424427 self .data = mujoco .MjData (self .model )
425428 assert id (self .model ) != id (event .model )
426- return True
429+ return False # Do not consume to allow other handlers to recieve the event.
427430
428431 @messages .handler (priority = messages .Priority .INTERNAL )
429432 def _on_exit (self , _ : messages .ExitEvent ) -> bool :
You can’t perform that action at this time.
0 commit comments