Skip to content

Commit d7c083a

Browse files
Improved robustness of recently added "OnCommandDestroy" event. The framework might trigger this for a UICommandTypeAnchor that is not stored in FCommands -> Ignore them
1 parent 4ddea9a commit d7c083a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Lib/UIRibbon.pas

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,8 @@ function TUIRibbon.OnCreateUICommand(CommandId: UInt32; TypeId: _UICommandType;
13601360
function TUIRibbon.OnDestroyUICommand(CommandId: UInt32; TypeId: _UICommandType; const CommandHandler: IUICommandHandler): HRESULT;
13611361
begin
13621362
//FCommands.Remove(CommandId); <- Code commented, because we might still have references to the command at this point. Since it is not ref-counted, we must not destroy it yet.
1363-
if Assigned(FOnCommandDestroy) then
1364-
FOnCommandDestroy(Self, FCommands[CommandId]);
1365-
1363+
if Assigned(FOnCommandDestroy) and TryGetCommand(CommandId, lCommand) then
1364+
FOnCommandDestroy(Self, lCommand);
13661365
Result := S_OK;
13671366
end;
13681367

0 commit comments

Comments
 (0)