Skip to content

Commit 8eb7f96

Browse files
author
joachim.marder
committed
Minor tweaks
1 parent f2971c0 commit 8eb7f96

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Lib/UIRibbonActions.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ procedure TUICommandRecentItemsActionLink.CommandSelect(
305305
Self.Selected.Description := (lItem as TUIRecentItem).Description;
306306
Self.Selected.Pinned := (lItem as TUIRecentItem).Pinned;
307307

308-
if Assigned(Action) then
309-
Action.Execute;
308+
if Assigned(Action) then
309+
Action.Execute;
310310
finally
311311
FreeAndNil(fSelected);
312312
end;

Lib/UIRibbonCommands.pas

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ function GetProperty(const Key: TUIPropertyKey): TUIProperty;
15951595
end;
15961596

15971597
type
1598+
15981599
{ This notifier is used for delayed notification of TUICommand's of specific
15991600
events. The notification will occur in the next message pump.
16001601
@@ -1622,14 +1623,17 @@ function GetProperty(const Key: TUIPropertyKey): TUIProperty;
16221623
TNotifierFlag = 0..31;
16231624

16241625
TNotifier = class
1625-
{$REGION 'Internal Declarations'}
1626+
strict private
1627+
// Type for storing the TUICommands
1628+
// We use Pointer here as generic type, because for those the hash value is being calculated without using the object instance.
1629+
// Since the messages are processed delayed, it may happen that the object instance has already been destroyed.
1630+
type TClients = TDictionary<Pointer, Cardinal>;
16261631
strict private
16271632
FNotificationWindow: HWND;
1628-
FClients: TDictionary<TUICommand, Cardinal>;
1633+
FClients: TClients;
16291634
strict private
16301635
procedure WndProc(var Msg: TMessage);
16311636
procedure Notify(const Command: TUICommand; const Flag: TNotifierFlag);
1632-
{$ENDREGION 'Internal Declarations'}
16331637
public
16341638
constructor Create;
16351639
destructor Destroy; override;
@@ -1656,7 +1660,7 @@ constructor TNotifier.Create;
16561660
begin
16571661
inherited;
16581662
FNotificationWindow := AllocateHWnd(WndProc);
1659-
FClients := TDictionary<TUICommand, Cardinal>.Create;
1663+
FClients := TClients.Create();
16601664
end;
16611665

16621666
destructor TNotifier.Destroy;
@@ -2027,7 +2031,7 @@ procedure TUICommand.Notify(const Flag: Integer);
20272031
Prop: TPair<TUIPropertyKey, TValue>;
20282032
Dec: TDecimal;
20292033
begin
2030-
if (Flag = NOTIFY_CACHED_PROPERTIES) then
2034+
if (Flag = NOTIFY_CACHED_PROPERTIES) and Assigned(FCachedProperties) then
20312035
begin
20322036
for Prop in FCachedProperties do
20332037
begin

0 commit comments

Comments
 (0)