From 3db28fa6a8bd586e317bdb28e6d5d767300dbc76 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Fri, 8 Nov 2013 03:02:45 +0000 Subject: [PATCH] richmemo: forcing handle allocation on set* operations (including load), to make sure that RichMemo system specific operations can be executed, #19662 git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2832 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index b7e85a39d..7acddbdbd 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -207,13 +207,15 @@ end; procedure TCustomRichMemo.SetTextAttributes(TextStart, TextLen: Integer; {SetMask: TTextStyleMask;} const TextParams: TFontParams); begin - if HandleAllocated then + if not HandleAllocated then HandleNeeded; + if HandleAllocated then TWSCustomRichMemoClass(WidgetSetClass).SetTextAttributes(Self, TextStart, TextLen, {SetMask,} TextParams); end; function TCustomRichMemo.GetTextAttributes(TextStart: Integer; var TextParams: TFontParams): Boolean; begin - if HandleAllocated then + if not HandleAllocated then HandleNeeded; + if HandleAllocated then Result := TWSCustomRichMemoClass(WidgetSetClass).GetTextAttributes(Self, TextStart, TextParams) else Result := false; @@ -245,6 +247,7 @@ procedure TCustomRichMemo.SetSelText(const SelTextUTF8: string); var st : Integer; begin + if not HandleAllocated then HandleNeeded; Lines.BeginUpdate; try st := SelStart; @@ -288,6 +291,8 @@ var l : Integer; p : TFontParams; begin + if not HandleAllocated then HandleNeeded; + if (ModifyMask = []) or (TextLength = 0) then Exit; i := TextStart; @@ -311,6 +316,7 @@ end; function TCustomRichMemo.LoadRichText(Source: TStream): Boolean; begin + if not HandleAllocated then HandleNeeded; if Assigned(Source) and HandleAllocated then begin Result := TWSCustomRichMemoClass(WidgetSetClass).LoadRichText(Self, Source); if not Result and Assigned(RTFLoadStream) then begin