1
0
mirror of synced 2024-11-14 16:33:54 +00:00

Fixed: AV when closing Delphi (at least 2007) due to IDE ActionList being destroyed before the package is unloaded

This commit is contained in:
Mark van Renswoude 2008-09-20 09:35:24 +00:00
parent 07d2233efd
commit 88aa236a62
3 changed files with 16 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@ type
end;
TBaseSwitcherHook = class(TObject)
TBaseSwitcherHook = class(TComponent)
private
FHookedActions: TList;
protected
@ -39,8 +39,10 @@ type
procedure OldActionExecute(AAction: TObject);
procedure OldActionUpdate(AAction: TObject);
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create();
constructor Create(); reintroduce;
destructor Destroy(); override;
end;
@ -54,7 +56,7 @@ uses
{ TBaseSwitcherHook }
constructor TBaseSwitcherHook.Create();
begin
inherited;
inherited Create(nil);
FHookedActions := TList.Create();
end;
@ -123,6 +125,7 @@ begin
AAction.OnUpdate := AOnUpdate;
FHookedActions.Add(hookedAction);
AAction.FreeNotification(Self);
end;
@ -155,20 +158,25 @@ begin
end;
procedure TBaseSwitcherHook.Notification(AComponent: TComponent; Operation: TOperation);
begin
if (Operation = opRemove) and (AComponent is TContainedAction) then
UnhookAction(TContainedAction(AComponent));
end;
procedure TBaseSwitcherHook.UnhookActionIndex(AIndex: Integer);
var
hookedAction: PHookedAction;
action: TContainedAction;
// onExecute: TNotifyEvent;
begin
hookedAction := FHookedActions[AIndex];
action := TContainedAction(hookedAction^.Action);
// onExecute := action.OnExecute;
action.RemoveFreeNotification(Self);
// if onExecute = hookedAction^.NewOnExecute then
action.OnExecute := hookedAction^.OldOnExecute;
action.OnUpdate := hookedAction^.OldOnUpdate;
action.OnExecute := hookedAction^.OldOnExecute;
action.OnUpdate := hookedAction^.OldOnUpdate;
Dispose(hookedAction);
FHookedActions.Delete(AIndex);