Browse Source

Fix crash when removing imagelist

lainz 5 years ago
parent
commit
3cf74d6f36
1 changed files with 9 additions and 0 deletions
  1. 9 0
      bgrathemebutton.pas

+ 9 - 0
bgrathemebutton.pas

@@ -25,6 +25,7 @@ type
     procedure SetState(AValue: TBGRAThemeButtonState);
     procedure TimerHoverElapse(Sender: TObject);
   protected
+    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     class function GetControlClassDefaultSize: TSize; override;
     procedure MouseEnter; override;
     procedure MouseLeave; override;
@@ -97,6 +98,14 @@ begin
   UpdateHoverState;
 end;
 
+procedure TBGRAThemeButton.Notification(AComponent: TComponent;
+  Operation: TOperation);
+begin
+  inherited Notification(AComponent, Operation);
+  if (Operation = opRemove) and (AComponent = FImageList) then
+    FImageList := nil;
+end;
+
 class function TBGRAThemeButton.GetControlClassDefaultSize: TSize;
 begin
   Result.CX := 125;