bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Remove need for EventLoopProxy to be NonSend

Open hymm opened this issue 1 year ago • 0 comments

Objective

  • Continue to pare down the uses on NonSend resources in the engine. In this case, EventLoopProxy used to be !Sync, but is now Sync in the latest version of winit.

Solution

  • New type EventLoopProxy as EventLoopProxyWrapper to make it into a normal resource.
  • Update the custom_user_event example as it no longer needs to indirectly access the EventLoopProxy through a static variable anymore.

Testing

  • Ran the example. The resource exists just for users to use, so there aren't any in engine uses for it currently.

Changelog

  • make EventLoopProxy into a regular resource.

Migration Guide

EventLoopProxy has been renamed to EventLoopProxyWrapper and is now Send, making it an ordinary resource.

Before:

event_loop_system(event_loop: NonSend<EventLoopProxy<MyEvent>>) {
    event_loop.send_event(MyEvent);
}

After:

event_loop_system(event_loop: Res<EventLoopProxy<MyEvent>>) {
    event_loop.send_event(MyEvent);
}

hymm avatar Jul 07 '24 02:07 hymm