bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Update `App:is_plugin_added` to work inside `Plugin::finish` and `Plugin::clean`

Open cBournhonesque opened this issue 1 year ago • 4 comments

Objective

I have been trying to check for the existing of some plugins via App::is_plugin_added to conditionally run some behaviour in the Plugin::finish part of my plugin, before realizing that the plugin registry is actually not available during this step. This is because the App::is_plugin_added using the plugin registry to check for previous registration.

Solution

  • Switch the App::is_plugin_added to use the list of plugin names to check for previous registrations
  • Add a unit test showcasing that App::is_plugin_added works during Plugin::finish

cBournhonesque avatar Mar 28 '24 13:03 cBournhonesque

instead of documenting it, could we make it work by checking against plugin_name_added in is_plugin_added?

mockersf avatar Mar 28 '24 23:03 mockersf

instead of documenting it, could we make it work by checking against plugin_name_added in is_plugin_added?

I made the change; if that sounds good, I can update the PR description

cBournhonesque avatar Mar 29 '24 02:03 cBournhonesque

Once conflicts are resolved I'll merge this in :)

alice-i-cecile avatar Apr 24 '24 17:04 alice-i-cecile

Once conflicts are resolved I'll merge this in :)

@alice-i-cecile I resolved the conflicts; I had to split the plugin_registry from the plugin_names (since the main idea of the change is that while we call std::mem::take(&mut self.plugin_registry) we still have access to plugin_names to check for is_plugin_added inside Plugin::finish and Plugin::clean

cBournhonesque avatar Apr 24 '24 18:04 cBournhonesque