Right mouse button over empty text item. Access violation.

General TRichView support forum. Please post your questions here
Post Reply
imkot
Posts: 2
Joined: Thu Jul 25, 2019 2:53 am

Right mouse button over empty text item. Access violation.

Post by imkot » Thu Jul 25, 2019 3:15 am

Install component from TRichViewSetup-Pre18.exe and ScaleRichViewSetup-Pre9.exe. Use Delphi XE8.

Create test application:

Code: Select all

type
  TForm5 = class(TForm)
    SRichViewEdit1: TSRichViewEdit;
    procedure FormCreate(Sender: TObject);
  private
    procedure CreateTest;
  public
  end;

var
  Form5: TForm5;

implementation

uses
  RVStyle, RVEdit;

{$R *.dfm}

procedure TForm5.CreateTest;
var
  curStyleNo: Integer;
  fi: TFontInfo;
  rve: TCustomRichViewEdit;
  textStyleNo: Integer;
begin
  rve := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  rve.InsertText('Click right mouse button here >');
  rve.InsertText('<', True);
  curStyleNo := rve.CurTextStyleNo;
  fi := TFontInfo.Create(nil);
  try
    fi.Assign(rve.Style.TextStyles[curStyleNo]);
    fi.EmptyWidth := 100;
    fi.Style := fi.Style + [fsUnderline];
    textStyleNo := rve.Style.TextStyles.FindSuchStyle(0, fi, RVAllFontInfoProperties);
    if textStyleNo < 0 then
    begin
      textStyleNo := rve.Style.TextStyles.Count;
      rve.Style.TextStyles.add.Assign(fi);
      rve.Style.TextStyles[textStyleNo].Standard := False;
    end;
    rve.CurTextStyleNo := textStyleNo;
    rve.InsertStringTag('', 'test');
  finally
    fi.Free;
    rve.CurTextStyleNo := curStyleNo;
  end;
end;

procedure TForm5.FormCreate(Sender: TObject);
begin
  CreateTest;
end;
Build and run application. Click right mouse button over empty text item, we get exception.
Who is to blame and what to do?

PS: Sorry my google-translate :)

Sergey Tkachenko
Site Admin
Posts: 14636
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Right mouse button over empty text item. Access violation.

Post by Sergey Tkachenko » Fri Jul 26, 2019 10:29 am

It's us to blame (
Quick fix for this bug: open CRVFData.pas, find TCustomRVFormattedData.FindWordAt_. In this procedure, change the line

Code: Select all

        if IsDelimiter(Word, RVGetStrIndex(Offs)) then
to

Code: Select all

        if (Word = '') or IsDelimiter(Word, RVGetStrIndex(Offs)) then

imkot
Posts: 2
Joined: Thu Jul 25, 2019 2:53 am

Re: Right mouse button over empty text item. Access violation.

Post by imkot » Mon Jul 29, 2019 5:05 am

Thank

Post Reply