Fixed: AV when closing Delphi (at least 2007) due to IDE ActionList being destroyed before the package is unloaded
This commit is contained in:
parent
07d2233efd
commit
88aa236a62
Binary file not shown.
Binary file not shown.
@ -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,18 +158,23 @@ 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user