From 6a197ad3ca8e0e32f8d3e844e9a5bde998c3746b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDeljan=20Rikalo?= Date: Sun, 13 Nov 2022 18:13:09 +0100 Subject: [PATCH] Qt5: fixed behaviour of TMemo.Lines.Add(), still slower than gtk or win32, but have correct behaviour when last line of memo is line break. For faster inserts remove last line break. issue #39444 --- lcl/interfaces/qt5/qtprivate.pp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/qt5/qtprivate.pp b/lcl/interfaces/qt5/qtprivate.pp index 751de2d8f0..ff7f395cad 100644 --- a/lcl/interfaces/qt5/qtprivate.pp +++ b/lcl/interfaces/qt5/qtprivate.pp @@ -437,11 +437,22 @@ begin // simplified because of issue #29670 // allow insert invalid index like others do if Index >= FStringList.Count then - Index := FStringList.Add(S) - else + begin + Index := FStringList.Add(S); + if FHasTrailingLineBreak then + W := GetUTF8String(S + LineBreak) + else + W := GetUTF8String(S); + if FHasTrailingLineBreak then + TQtTextEdit(FOwner.Handle).setLineText(Index, W) + else + TQtTextEdit(FOwner.Handle).Append(W); + end else + begin FStringList.Insert(Index, S); - W := GetUTF8String(S); - TQtTextEdit(FOwner.Handle).insertLine(Index, W); + W := GetUTF8String(S); + TQtTextEdit(FOwner.Handle).insertLine(Index, W); + end; FTextChanged := False; // FStringList is already updated, no need to update from WS. end;