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