Bugzilla – Bug 5274
Global event when any plugin is loaded/unloaded.
Last modified: 2014-05-30 10:49:07 PDT
I've been writing plenty of plugins recently with powerful API's (Such as Improved Commands and Plugin Categories) but I've found that requiring every plugin to unregister functions when they're being unloaded is a bit...impractical, especially considering (at least the original, fastest version of) Plugin Categories can be used without any modifications to the plugins in question. If a plugin is late loaded, no other plugin will have any idea that this happened, unless a native is called notifying the main plugin of the load. Please excuse my rambling request, but I have talked to several people in #sourcemod who definitely agree that there's a need for these events. Examples: forward OnPluginLateLoad(Handle:plugin); forward OnPluginRemoved(Handle:plugin);
*** Bug 5663 has been marked as a duplicate of this bug. ***
Created attachment 3297 [details] [review] Expose OnPluginLoaded and OnPluginUnloaded to SP. I can't speak to the validity of OnPluginLoaded (because I have no current use case for it, others probably (definitely) do). This patch has a forward for both cases. From the (half) duplicate bug (Bug 5663): It's possible to create APIs that use handles in Pawn. However, without the plugin notifying the main plugin that they have unloaded, stale references can be left over, resulting in a waste of memory (also handle leaks). While it's the foreign plugin author's fault if this happens, it would be nice if plugins could have a chance to know when user plugins are unloaded in an effort to cleanup, just like extensions. An alternative would be to create hooks for RegPluginLibrary to fire functions in their parent plugins if their children die (unload). However, that's a bigger change, and not every plugin would require/follow this.
Add this feature already, it is really useful.
(In reply to black---rabbit from comment #3) Do not bump bug reports unless explicitly asked. You can add yourself to the CC list to be sent an automatic e-mail notification if and when we do make a change to a report.