@@ -1595,6 +1595,7 @@ function GetProperty(const Key: TUIPropertyKey): TUIProperty;
15951595end ;
15961596
15971597type
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;
16561660begin
16571661 inherited ;
16581662 FNotificationWindow := AllocateHWnd(WndProc);
1659- FClients := TDictionary<TUICommand, Cardinal> .Create;
1663+ FClients := TClients .Create() ;
16601664end ;
16611665
16621666destructor TNotifier.Destroy;
@@ -2027,7 +2031,7 @@ procedure TUICommand.Notify(const Flag: Integer);
20272031 Prop: TPair<TUIPropertyKey, TValue>;
20282032 Dec: TDecimal;
20292033begin
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