mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
Qt4,Qt5,Qt6: fixed slowness when appending text into WS control. issue #39444
This commit is contained in:
parent
a3f22577f1
commit
04ffdbc374
@ -423,6 +423,10 @@ end;
|
||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
W: WideString;
|
||||
ATextEdit: QTextEditH;
|
||||
ADoc: QTextDocumentH;
|
||||
ABlock: QTextBlockH;
|
||||
ACursor: QTextCursorH;
|
||||
begin
|
||||
if FTextChanged then InternalUpdate;
|
||||
if Index < 0 then Index := 0;
|
||||
@ -434,11 +438,32 @@ 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 := UTF8ToUTF16(S + LineBreak)
|
||||
else
|
||||
W := UTF8ToUTF16(S);
|
||||
//issue #39444
|
||||
if FHasTrailingLineBreak then
|
||||
begin
|
||||
ATextEdit := QTextEditH(TQtTextEdit(FOwner.Handle).Widget);
|
||||
ADoc := QTextEdit_document(ATextEdit);
|
||||
ABlock := QTextBlock_Create;
|
||||
QTextDocument_lastBlock(ADoc, ABlock);
|
||||
ACursor := QTextCursor_Create(ABlock);
|
||||
QTextCursor_movePosition(ACursor, QTextCursorEnd);
|
||||
QTextCursor_deletePreviousChar(ACursor);
|
||||
QTextBlock_Destroy(ABlock);
|
||||
QTextCursor_destroy(ACursor);
|
||||
end;
|
||||
TQtTextEdit(FOwner.Handle).Append(W);
|
||||
end else
|
||||
begin
|
||||
FStringList.Insert(Index, S);
|
||||
W := {%H-}S;
|
||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||
W := UTF8ToUTF16(S);
|
||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||
end;
|
||||
FTextChanged := False; // FStringList is already updated, no need to update from WS.
|
||||
end;
|
||||
|
||||
|
@ -426,6 +426,10 @@ end;
|
||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
W: WideString;
|
||||
ATextEdit: QTextEditH;
|
||||
ADoc: QTextDocumentH;
|
||||
ABlock: QTextBlockH;
|
||||
ACursor: QTextCursorH;
|
||||
begin
|
||||
if FTextChanged then InternalUpdate;
|
||||
if Index < 0 then Index := 0;
|
||||
@ -444,9 +448,19 @@ begin
|
||||
else
|
||||
W := GetUTF8String(S);
|
||||
if FHasTrailingLineBreak then
|
||||
TQtTextEdit(FOwner.Handle).setLineText(Index, W)
|
||||
else
|
||||
TQtTextEdit(FOwner.Handle).Append(W);
|
||||
begin
|
||||
//issue #39444
|
||||
ATextEdit := QTextEditH(TQtTextEdit(FOwner.Handle).Widget);
|
||||
ADoc := QTextEdit_document(ATextEdit);
|
||||
ABlock := QTextBlock_Create;
|
||||
QTextDocument_lastBlock(ADoc, ABlock);
|
||||
ACursor := QTextCursor_Create(ABlock);
|
||||
QTextCursor_movePosition(ACursor, QTextCursorEnd);
|
||||
QTextCursor_deletePreviousChar(ACursor);
|
||||
QTextBlock_Destroy(ABlock);
|
||||
QTextCursor_destroy(ACursor);
|
||||
end;
|
||||
TQtTextEdit(FOwner.Handle).Append(W);
|
||||
end else
|
||||
begin
|
||||
FStringList.Insert(Index, S);
|
||||
|
@ -426,6 +426,10 @@ end;
|
||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
W: WideString;
|
||||
ATextEdit: QTextEditH;
|
||||
ADoc: QTextDocumentH;
|
||||
ABlock: QTextBlockH;
|
||||
ACursor: QTextCursorH;
|
||||
begin
|
||||
if FTextChanged then InternalUpdate;
|
||||
if Index < 0 then Index := 0;
|
||||
@ -444,9 +448,19 @@ begin
|
||||
else
|
||||
W := GetUTF8String(S);
|
||||
if FHasTrailingLineBreak then
|
||||
TQtTextEdit(FOwner.Handle).setLineText(Index, W)
|
||||
else
|
||||
TQtTextEdit(FOwner.Handle).Append(W);
|
||||
begin
|
||||
//issue #39444
|
||||
ATextEdit := QTextEditH(TQtTextEdit(FOwner.Handle).Widget);
|
||||
ADoc := QTextEdit_document(ATextEdit);
|
||||
ABlock := QTextBlock_Create;
|
||||
QTextDocument_lastBlock(ADoc, ABlock);
|
||||
ACursor := QTextCursor_Create(ABlock);
|
||||
QTextCursor_movePosition(ACursor, QTextCursorEnd);
|
||||
QTextCursor_deletePreviousChar(ACursor);
|
||||
QTextBlock_Destroy(ABlock);
|
||||
QTextCursor_destroy(ACursor);
|
||||
end;
|
||||
TQtTextEdit(FOwner.Handle).Append(W);
|
||||
end else
|
||||
begin
|
||||
FStringList.Insert(Index, S);
|
||||
|
Loading…
Reference in New Issue
Block a user