RichMemo/WorkArounds

From Lazarus wiki
Revision as of 09:47, 28 August 2017 by Dbannon (talk | contribs) (Start a page about how to work around some bugs in RichMemo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

RichMemo is a great application (thank you Dmitry!) but its not finished. This page lists some work arounds for some incomplete RichMemo functions. Its important to note that the things mentioned here are NOT official characteristics of RichMemo. They are things found to work in the current release. Its likely they will change in the future, please don't assume that they will continue to work or even that they will even continue to be needed.

If you use any of these work arounds, mark your code accordingly and test carefully when you update RichMemo ! If you don't need a work around, get rid of it, some of these here are quite ugly !

GetTextAttributes()

The problem : RichMemo.GetTextAttributes() does not return false when first param is out of range. First Param to this function points to a char in the Memo that it should report on. The function is described as returning False if the indicated char is somehow invalid. However, passing -1 or a number greater than RichMemo.GetTexLen() returns True. The function works fine under Linux.

Documented at RichMemo#GetTextAttributes

Logged https://bugs.freepascal.org/view.php?id=32296

The Test

if Richmemo1.GetTextAttributes(-1, FP) then showmessage('Failed on -1');
if Richmemo1.GetTextAttributes(30000, FP) then showmessage('Failed on 30000');


The Fix An easy fix appears to be to add a test at entry into the function, insert into line 677 of RichMemo.pas -

677 Result := False;
678 if (textStart = GetTextLen) then exit();

Its unnecessary under linux but does no harm, possibly even returns false a touch faster under Linux ? I have tested under Win10 and GTK2 based Linux.