You've already forked lazarus-ccr
SpkToolbar: Fix crash when a popupmenu used by a button is destroyed.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8962 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -15,7 +15,7 @@ unit spkt_Pane;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uses LazLoggerBase,
|
||||
Graphics, Controls, Classes, SysUtils, Math, Dialogs,
|
||||
SpkGraphTools, SpkGUITools, SpkMath,
|
||||
spkt_Appearance, spkt_Const, spkt_Dispatch, spkt_Exceptions,
|
||||
@ -172,7 +172,7 @@ type
|
||||
function Add: TSpkPane;
|
||||
function Insert(AIndex: integer): TSpkPane;
|
||||
|
||||
// *** Reaction to changes in the list ***
|
||||
// *** Reaction to changes ***
|
||||
procedure Notify(Item: TComponent; Operation: TOperation); override;
|
||||
procedure Update; override;
|
||||
|
||||
@ -398,11 +398,11 @@ begin
|
||||
|
||||
// Pane label
|
||||
ABuffer.Canvas.Font.Assign(FAppearance.Pane.CaptionFont);
|
||||
w := ABuffer.Canvas.TextWidth(FCaption); // Panel label width
|
||||
|
||||
// Handle visibility of 'More options' button to set Pane label pos
|
||||
// Handle visibility of 'More options' button to set Pane label position
|
||||
if FShowMoreOptionsButton then
|
||||
begin
|
||||
w := ABuffer.Canvas.TextWidth(FCaption);
|
||||
if isRTL then
|
||||
x := FRect.Right - (FRect.Width - PaneMoreOptionsButtonWidth - w) div 2 - w
|
||||
else
|
||||
@ -1347,10 +1347,16 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSpkPanes.Notify(Item: TComponent; Operation: TOperation);
|
||||
var
|
||||
i: Integer;
|
||||
pane: TSpkPane;
|
||||
begin
|
||||
inherited Notify(Item, Operation);
|
||||
DebugLn('[TSpkPanes.Notify] Removing ' + Item.ClassName);
|
||||
|
||||
case Operation of
|
||||
opInsert:
|
||||
if Item is TSpkPane then
|
||||
begin
|
||||
// Setting the dispatcher to nil will cause that during the
|
||||
// ownership assignment, the Notify method will not be called
|
||||
@ -1365,17 +1371,24 @@ begin
|
||||
TSpkPane(Item).ToolbarDispatch := FToolbarDispatch;
|
||||
end;
|
||||
opRemove:
|
||||
if not(csDestroying in Item.ComponentState) then
|
||||
if Item is TSpkPane then
|
||||
begin
|
||||
TSpkPane(Item).ToolbarDispatch := nil;
|
||||
TSpkPane(Item).Appearance := nil;
|
||||
TSpkPane(Item).Images := nil;
|
||||
TSpkPane(Item).DisabledImages := nil;
|
||||
TSpkPane(Item).LargeImages := nil;
|
||||
TSpkPane(Item).DisabledLargeImages := nil;
|
||||
// TSpkPane(Item).ImagesWidth := 0;
|
||||
// TSpkPane(Item).LargeImagesWidth := 0;
|
||||
end;
|
||||
if not(csDestroying in Item.ComponentState) then
|
||||
begin
|
||||
TSpkPane(Item).ToolbarDispatch := nil;
|
||||
TSpkPane(Item).Appearance := nil;
|
||||
TSpkPane(Item).Images := nil;
|
||||
TSpkPane(Item).DisabledImages := nil;
|
||||
TSpkPane(Item).LargeImages := nil;
|
||||
TSpkPane(Item).DisabledLargeImages := nil;
|
||||
end;
|
||||
end else
|
||||
for i := 0 to Count-1 do
|
||||
begin
|
||||
pane := Items[i];
|
||||
DebugLn(['pane ', pane.Caption]);
|
||||
pane.Items.Notify(Item, Operation);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user