Page 1 of 1

Access Violation in RVDXRibbonDemo - EListError 'List index out of bounds (-1)'

Posted: Mon Jan 27, 2025 10:29 am
by Fab85
Hello,

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;
The issue seems related to the following procedure:

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;
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:

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);
Can you confirm if this is the correct approach or suggest an alternative fix?

Re: Access Violation in RVDXRibbonDemo - EListError 'List index out of bounds (-1)'

Posted: Mon Jan 27, 2025 12:37 pm
by Sergey Tkachenko
Can you post the complete call stack at the moment in exception?
To copy it to the Clipboard, when the exception happens, go to the Call Stack windows (Ctrl+Alt+S), select all items (Ctrl+A) and copy (Ctrl+C).

Re: Access Violation in RVDXRibbonDemo - EListError 'List index out of bounds (-1)'

Posted: Mon Jan 27, 2025 1:55 pm
by Fab85
Callstack is :

Code: Select all

:76801722 KERNELBASE.RaiseException + 0x62
System.Classes.TList.Get(-1)
:002edae9 TList.Get + $19
System.Classes.TList.Get(???)
RVItem.TRVItemList.GetObject(-1)
RichView.TCustomRichView.GetItem(-1)
RVEdit.TCustomRichViewEdit.GetCurrentItemEx(TRVTableItemInfo,$A52D600,nil)
MainFrm.TfrmMain.RichViewEdit1CaretMove($A52D600)
MainFrm.TfrmMain.RichViewEdit1Enter($A52D600)
Vcl.Controls.TWinControl.DoEnter
Vcl.Controls.TWinControl.CMEnter(???)
Vcl.Controls.TControl.WndProc((45082, 0, 0, 0, 0, 0, (), 0, 0, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((45082, 0, 0, 0, 0, 0, (), 0, 0, (), 0, 0, ()))
RichView.TCustomRichView.WndProc((45082, 0, 0, 0, 0, 0, (), 0, 0, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(5571828,45082,0,0)
:7697164b USER32.AddClipboardFormatListener + 0x4b
:76967dba ; C:\WINDOWS\SysWOW64\USER32.dll
:769679ba ; C:\WINDOWS\SysWOW64\USER32.dll
:7696be8f ; C:\WINDOWS\SysWOW64\USER32.dll
:775554bd ntdll.KiUserCallbackDispatcher + 0x4d
:769660bd USER32.SendMessageW + 0x4d
Vcl.Forms.SendFocusMessage(???,???)
:0047fcbd SendFocusMessage + $15
Vcl.Controls.TWinControl.WndProc((7, 2228610, 0, 0, 386, 34, (), 0, 0, (), 0, 0, ()))
RichView.TCustomRichView.WndProc((7, 2228610, 0, 0, 386, 34, (), 0, 0, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(5571828,7,2228610,0)
:7697164b USER32.AddClipboardFormatListener + 0x4b
:76967dba ; C:\WINDOWS\SysWOW64\USER32.dll
:769679ba ; C:\WINDOWS\SysWOW64\USER32.dll
:7696be8f ; C:\WINDOWS\SysWOW64\USER32.dll
:775554bd ntdll.KiUserCallbackDispatcher + 0x4d
RVScroll.TRVScroller.SetFocusSilent
RVDXBarItems.TdxBarCustomRVCombo.FocusEditor
RVDXBarItems.TdxBarCustomRVCombo.SetText('')
dxBar.TdxBarCustomCombo.SetItemIndex(-1)
dxBar.TdxBarCustomCombo.ItemsChanged($BAB70C0)
System.Classes.TStringList.Changed
System.Classes.TStringList.Clear
RVStyleFuncs.RVFillListWithStyleTemplates($BAB70C0,$A52D600,True,True,True,$BB2D010)
RVDXBarItems.TdxBarRVFStyleTemplateCombo.Build
RVDXBarItems.TdxBarRVFStyleTemplateCombo.DoFill($A52D600)
RVEventHandlers.TRVEventHandlerList.Execute($A52D600)
RVDataRootPropsEx.TRVDataRootEventsEx.ExecuteStyleTemplatesChange
RVRVData.TRichViewRVData.DoStyleTemplatesChange
RVRTFProps.TRVRTFReaderProperties.ReadFromStream($F1B5F38,$BB0F680,False,rvlfRTF)
CRVData.TCustomRVData.LoadRTFOrDocXFromStream($F1B5F38,rvlfRTF)
CRVData.TCustomRVData.LoadRTFFromStream($F1B5F38)
RichView.TCustomRichView.LoadRTFFromStream($F1B5F38)
MainFrm.TfrmMain.Button1Click($A5D5DF0)
Vcl.Controls.TControl.Click
Vcl.StdCtrls.TCustomButton.Click
Vcl.StdCtrls.TCustomButton.CNCommand(???)
Vcl.Controls.TControl.WndProc((48401, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((48401, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.StdCtrls.TButtonControl.WndProc((48401, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.Controls.TControl.Perform(???,???,2228610)
Vcl.Controls.DoControlMsg(???,(aucune valeur))
Vcl.Controls.TWinControl.WMCommand((273, (), 386, 0, (), 2228610, 0))
Vcl.Forms.TCustomForm.WMCommand((273, (), 386, 0, (), 2228610, 0))
Vcl.Controls.TControl.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.Forms.TCustomForm.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
dxForms.TdxForm.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
dxCustomFluentDesignForm.TdxCustomFluentDesignForm.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
dxRibbonForm.TdxCustomRibbonForm.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
cxControls.TcxWindowProcLinkedObject.DefaultProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
dxShadowWindow.TdxShadowWindow.OwnerWindowWndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
cxControls.TcxWindowProcLinkedObject.DefaultProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
dxBar.TdxBarManager.OwnerWindowProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
cxControls.TcxWindowProcLinkedObjectList.WndProc((273, 386, 2228610, 0, 386, 0, (), 386, 34, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(2753462,273,386,2228610)
:7697164b USER32.AddClipboardFormatListener + 0x4b
:76967dba ; C:\WINDOWS\SysWOW64\USER32.dll
:769679ba ; C:\WINDOWS\SysWOW64\USER32.dll
:7696be8f ; C:\WINDOWS\SysWOW64\USER32.dll
:775554bd ntdll.KiUserCallbackDispatcher + 0x4d
:769660bd USER32.SendMessageW + 0x4d
:6f5365e8 ; C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_a865f0c28672571c\COMCTL32.dll
:6f575f73 ; C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_a865f0c28672571c\COMCTL32.dll
:7697164b USER32.AddClipboardFormatListener + 0x4b
:76967dba ; C:\WINDOWS\SysWOW64\USER32.dll
:76967576 ; C:\WINDOWS\SysWOW64\USER32.dll
:76965d9b USER32.CallWindowProcW + 0x1b
Vcl.Controls.TWinControl.DefaultHandler(???)
:003a0ce2 TWinControl.DefaultHandler + $136
:003a0b8c TWinControl.WndProc + $6AC
:003c3d61 TButtonControl.WndProc + $71
:00306992 StdWndProc + $16
:7697164b USER32.AddClipboardFormatListener + 0x4b
:76967dba ; C:\WINDOWS\SysWOW64\USER32.dll
:769666f1 ; C:\WINDOWS\SysWOW64\USER32.dll
:76966210 USER32.DispatchMessageW + 0x10

Re: Access Violation in RVDXRibbonDemo - EListError 'List index out of bounds (-1)'

Posted: Mon Jan 27, 2025 6:05 pm
by Sergey Tkachenko
Yes, your check (rve.CurItemNo <> -1) is correct.