Bug 5274 - Global event when any plugin is loaded/unloaded.
Global event when any plugin is loaded/unloaded.
Status: UNCONFIRMED
Product: SourceMod
Classification: Unclassified
Component: Core
master
All All
: P5 enhancement
Assigned To: SourceMod Bugs
:
: 5663 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-11 18:41 PDT by necavi
Modified: 2014-05-30 10:49 PDT (History)
8 users (show)

See Also:


Attachments
Expose OnPluginLoaded and OnPluginUnloaded to SP. (4.64 KB, patch)
2013-03-18 15:49 PDT, Kyle Sanderson
kyle.leet: review? (skamonkey)
kyle.leet: feedback? (drifter01620)
Details | Diff | Splinter Review

Description necavi 2012-04-11 18:41:05 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);
Comment 1 Erin Baker [:asherkin] 2013-03-17 13:38:21 PDT
*** Bug 5663 has been marked as a duplicate of this bug. ***
Comment 2 Kyle Sanderson 2013-03-18 15:49:12 PDT
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.
Comment 3 black---rabbit 2014-01-26 19:50:12 PST
Add this feature already, it is really useful.
Comment 4 Nicholas Hastings [:psychonic] 2014-01-26 19:55:01 PST
(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.

Note You need to log in before you can comment on or make changes to this bug.