Crash when hitting RETURN on a selected link (solution included)
manliomazzon opened this issue · 1 comments
When a link is selected (possibly with TAB key), if I hit RETURN the program often crashes.
After some digging, I solved the problem by adding the line Key := 0; in the following method. (I.e. after consuming the vk_Return key stroke, set it to zero so that it is not handled further, which causes the crash on my Lazarus compiled app)
procedure TFontObj.AKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
Viewer: THtmlViewer;
begin
Viewer := THtmlViewer(FSection.Document.TheOwner);
if (Key = vk_Return) then
begin
Viewer.Url := UrlTarget.Url;
Viewer.Target := UrlTarget.Target;
Viewer.LinkAttributes.Text := UrlTarget.Attr;
Viewer.LinkText := Viewer.GetTextByIndices(UrlTarget.Start, UrlTarget.Last);
Viewer.TriggerUrlAction; {call to UrlAction via message}
Key := 0; // <<<<<<<------------------------------------------------- This line solves the crash
end
else {send other keys to THtmlViewer}
Viewer.KeyDown(Key, Shift);
end;
Thanks for spotting this issue.
Commit afa0893 fixes it in the master branch.