Access Violation in RVDXRibbonDemo - EListError 'List index out of bounds (-1)'
Posted: Mon Jan 27, 2025 10:29 am
Hello,
I am encountering an issue with the RVDXRibbonDemo project. Specifically, it raises an]EListErrorexception with the message:
Here is the code that triggers the error:
The issue seems related to the following procedure:
When there is no current item (CurItemNo = -1), the procedure raises the exception.
Possible Solution ?
Changing the visibility condition to check CurItemNo may resolve the issue:
Can you confirm if this is the correct approach or suggest an alternative fix?
I am encountering an issue with the RVDXRibbonDemo project. Specifically, it raises an]EListErrorexception with the message:
Code: Select all
'List index out of bounds (-1). The range of TRVItemList is 0..0.'
Here is the code that triggers the error:
Code: Select all
procedure TfrmMain.Button1Click(Sender: TObject);
var
LTextString: TStringStream;
begin
LTextString := TStringStream.Create;
try
LTextString.WriteString(
'{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fnil\fcharset0 Calibri;}}' +
'{\*\generator Riched20 10.0.22621}\viewkind4\uc1' +
'\pard\sa200\sl276\slmult1\f0\fs22\lang12 Line 1\par' +
'}'
);
LTextString.Position := 0;
RichViewEdit1.BeginUpdate;
RichViewEdit1.ClearAll;
RichViewEdit1.LoadRTFFromStream(LTextString);
RichViewEdit1.ReformatAll; // same with RichViewEdit1.Reformat
RichViewEdit1.EndUpdate;
finally
LTextString.Free;
end;
end;
Code: Select all
procedure TFormCourrierPleinePageTRichView.RichViewEdit1CaretMove(Sender: TObject);
var
Item: TCustomRVItemInfo;
rve: TCustomRichViewEdit;
begin
rve := Sender as TCustomRichViewEdit;
if rve <> RVAControlPanel1.DefaultControl then
Exit;
dxRibbonDefaut.Contexts[0].Visible :=
(rve.ItemCount > 0) and rve.GetCurrentItemEx(TRVTableItemInfo, rve, Item);
end;
Possible Solution ?
Changing the visibility condition to check CurItemNo may resolve the issue:
Code: Select all
dxRibbonDefaut.Contexts[0].Visible :=
(rve.CurItemNo <> -1) // Added condition to check if the current item is valid
and (rve.ItemCount > 0)
and rve.GetCurrentItemEx(TRVTableItemInfo, rve, Item);