From 080e9177b5f7fb1a8ca8a67800c7d116ccec9980 Mon Sep 17 00:00:00 2001 From: juha Date: Thu, 20 Sep 2018 08:18:59 +0000 Subject: [PATCH] IDE: Cleanup + sanity checks for deleting IDE Coolbar's Toolbar. Issue #34302. git-svn-id: trunk@59093 - --- ide/frames/idecoolbar_options.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ide/frames/idecoolbar_options.pas b/ide/frames/idecoolbar_options.pas index 1c1a7ef419..7e53f28f3a 100644 --- a/ide/frames/idecoolbar_options.pas +++ b/ide/frames/idecoolbar_options.pas @@ -439,13 +439,14 @@ begin begin if MessageDlg(lisCoolbarDeleteToolBar, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin - if ToDelete + 1 < CoolBar.Bands.Count then + if ToDelete < CoolBar.Bands.Count-1 then SelectBand(ToDelete + 1) - else if ToDelete - 1 >= 0 then + else if ToDelete > 0 then SelectBand(ToDelete - 1); I := FTempCoolBar.FindByToolBar((CoolBar.Bands.Items[ToDelete].Control as TToolBar)); - if I <> -1 then - FTempCoolBar.ToolBars.Delete(I); + Assert(I = ToDelete, 'TIdeCoolbarOptionsFrame.bDeleteClick: index mismatch.'); + // CoolBar Band gets deleted at the same go with FTempCoolBar item. + FTempCoolBar.ToolBars.Delete(ToDelete); end; end; EnableDisableToolbarButtons;