Skip to content

Commit dfee965

Browse files
Set fRecentItems to nil when the command or window handle is destroyed.
This ensures that it will be recreated correctly when the window handle is recreated
1 parent ca637b2 commit dfee965

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/UIRibbon.pas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ procedure TUIRibbon.DestroyWnd;
12591259
if (csRecreating in ControlState) then
12601260
LoadFramework;
12611261
FCommands.Clear;
1262+
fRecentItems := nil; //Destroying the window handle does not necessarily call OnDestroyUICommand for the recent items command, so we might have to set the reference to nil here.
12621263
fLoaded := False;
12631264
end;
12641265

@@ -1372,6 +1373,8 @@ function TUIRibbon.OnDestroyUICommand(CommandId: UInt32; TypeId: _UICommandType;
13721373
lCommand: TUICommand;
13731374
begin
13741375
//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.
1376+
if TUICommandType(TypeId) = TUICommandType.ctRecentItems then
1377+
fRecentItems := nil;
13751378
if Assigned(FOnCommandDestroy) and TryGetCommand(CommandId, lCommand) then
13761379
FOnCommandDestroy(Self, lCommand);
13771380
Result := S_OK;
@@ -1460,7 +1463,7 @@ procedure TUIRibbon.SaveRibbonSettings;
14601463
except
14611464
on E: EFileStreamError do
14621465
begin
1463-
OutputDebugString(PChar('An EFileStreamError error occured while trying to save the ribbon settings: ' + E.Message));
1466+
OutputDebugString(PChar('An EFileStreamError error occurred while trying to save the ribbon settings: ' + E.Message));
14641467
{$ifdef DEBUG}
14651468
raise e;
14661469
{$endif}

0 commit comments

Comments
 (0)