On occasion the RichEditor.ContentHeight returns a very large value (181mln and more). Tracing shows that at the moment of calling ContentHeight the property RichEditor.Canvas = nil. As a result TTMSFMXRichEditor.GetTextSize() returns a TTextSize record with "strange" values.
The code is straight foreward and resembles similar code elswhere in the application:
TFrameAnswer_MC = class(TFrameAnswer_Custom)
layoutCheckmark: TLayout;
layoutButton: TLayout;
layoutAnswer: TLayout;
btnAnswer: TButton;
reText: TTMSFMXRichEditor;
private
{ Private declarations }
public
procedure Display; override;
end;
with
procedure TFrameAnswer_MC.Display;
var
newHeight: single;
contentHeight: integer;
begin
if Assigned( Answer ) then
begin
LoadHTML( reText, TAnswer_MC(Answer).Text );
contentHeight := reText.ContentHeight;
newHeight := Max( reText.ContentHeight, btnAnswer.Height + 8 );
end;
end;
The debugger also shows that RichEditor.Canvas is already nil after creation.
The parent frame does not do anything regarding the creation:
TFrameAnswer_Custom = class(TFrame)
HTMLIO: TTMSFMXRichEditorMiniHTMLIO;
private
fAnswer: TCustomAnswer;
fPageGroup: TPageGroup;
procedure SetAnswer(const Value: TCustomAnswer);
procedure SetPageGroup(const Value: TPageGroup);
{ Private declarations }
public
procedure LoadHTML( aRichEditor: TTMSFMXRichEditor; aSource: string );
procedure Display; virtual; abstract;
property Answer: TCustomAnswer read fAnswer write SetAnswer;
property PageGroup: TPageGroup read fPageGroup write SetPageGroup;
end;
Question:
Do you have a clue in what cases RichEditor.Canvas = nil can become nil at frame creation time?