View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0005376 | JEDI VCL | 03 Donations | public | 2010-10-25 20:01 | 2012-02-29 16:53 |
| Reporter | masonwheeler | Assigned To | obones | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | resolved | Resolution | fixed | ||
| Product Version | |||||
| Target Version | Fixed in Version | 3.45 | |||
| Summary | 0005376: Unload notification events for JvPlugin | ||||
| Description | I recently found that, due to a quirk in the way LoadPackage initializes contained units, I needed to add some specialized package-management capabilities to my program. It was pretty easy to implement on top of JvPlugin, except for one minor issue: I had no notification when a plugin was being unloaded! We have event handlers that fire when a package is loaded, but not when one is unloaded. So I wrote up a little patch for it to add unload event handlers. Submitting it here per the MPL. | ||||
| Tags | No tags attached. | ||||
|
2010-10-25 20:01
|
jvcl.diff (2,460 bytes)
Index: JvPluginManager.pas
===================================================================
--- JvPluginManager.pas (revision 12678)
+++ JvPluginManager.pas (working copy)
@@ -97,6 +97,9 @@
TJvBeforeLoadEvent = procedure(Sender: TObject; FileName: string; var AllowLoad: Boolean) of object;
TJvAfterLoadEvent = procedure(Sender: TObject; FileName: string;
const ALibHandle: THandle; var AllowLoad: Boolean) of object;
+ TJvBeforeUnloadEvent = procedure(Sender: TObject; FileName: string;
+ const ALibHandle: THandle) of object;
+ TJvAfterUnloadEvent = procedure(Sender: TObject; FileName: string) of object;
TJvBeforeCommandsEvent = procedure(Sender: TObject; APlugIn: TJvPlugIn) of object;
TJvAfterCommandsEvent = procedure(Sender: TObject; APlugIn: TJvPlugIn) of object;
TJvPlgInErrorEvent = procedure(Sender: TObject; AError: Exception) of object;
@@ -128,6 +131,8 @@
FPluginInfos: TList;
FOnBeforeLoad: TJvBeforeLoadEvent;
FOnAfterLoad: TJvAfterLoadEvent;
+ FOnBeforeUnload: TJvBeforeUnloadEvent;
+ FOnAfterUnload: TJvAfterUnloadEvent;
FOnNewCommand: TNewCommandEvent;
FOnBeforeNewCommand: TJvBeforeCommandsEvent;
@@ -162,6 +167,8 @@
property OnBeforeLoad: TJvBeforeLoadEvent read FOnBeforeLoad write FOnBeforeLoad;
property OnNewCommand: TNewCommandEvent read FOnNewCommand write FOnNewCommand;
property OnAfterLoad: TJvAfterLoadEvent read FOnAfterLoad write FOnAfterLoad;
+ property OnBeforeUnload: TJvBeforeUnloadEvent read FOnBeforeUnload write FOnBeforeUnload;
+ property OnAfterUnload: TJvAfterUnloadEvent read FOnAfterUnload write FOnAfterUnload;
property OnBeforeNewCommand: TJvBeforeCommandsEvent read FOnBeforeNewCommand write FOnBeforeNewCommand;
property OnAfterNewCommand: TJvAfterCommandsEvent read FOnAfterNewCommand write FOnAfterNewCommand;
property OnPlugInError: TJvPlgInErrorEvent read FOnPlugInError write FOnPlugInError;
@@ -473,12 +480,18 @@
procedure TJvPluginManager.UnloadPlugin(Index: Integer);
var
PlgI: TPluginInfo;
+ name: string;
begin
PlgI := FPluginInfos.Items[Index];
+ name := PlgI.PlugIn.FileName;
+ if assigned(FOnBeforeUnload) then
+ FOnBeforeUnload(self, name, PlgI.Handle);
PlgI.PlugIn.Free;
UnloadLibrary(PlgI.PluginKind, PlgI.Handle);
PlgI.Free;
FPluginInfos.Delete(Index);
+ if assigned(FOnAfterUnload) then
+ FOnAfterUnload(self, name);
end;
{$WARN SYMBOL_DEPRECATED OFF}
|
|
|
Thank you, this is now in SVN |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-10-25 20:01 | masonwheeler | New Issue | |
| 2010-10-25 20:01 | masonwheeler | File Added: jvcl.diff | |
| 2010-11-09 14:22 | obones | Note Added: 0018040 | |
| 2010-11-09 14:22 | obones | Status | new => resolved |
| 2010-11-09 14:22 | obones | Fixed in Version | => Daily / SVN |
| 2010-11-09 14:22 | obones | Resolution | open => fixed |
| 2010-11-09 14:22 | obones | Assigned To | => obones |
| 2012-02-29 16:53 | obones | Fixed in Version | Daily / SVN => 3.45 |