mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 08:59:13 +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);
|
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||||
var
|
var
|
||||||
W: WideString;
|
W: WideString;
|
||||||
|
ATextEdit: QTextEditH;
|
||||||
|
ADoc: QTextDocumentH;
|
||||||
|
ABlock: QTextBlockH;
|
||||||
|
ACursor: QTextCursorH;
|
||||||
begin
|
begin
|
||||||
if FTextChanged then InternalUpdate;
|
if FTextChanged then InternalUpdate;
|
||||||
if Index < 0 then Index := 0;
|
if Index < 0 then Index := 0;
|
||||||
@ -434,11 +438,32 @@ begin
|
|||||||
// simplified because of issue #29670
|
// simplified because of issue #29670
|
||||||
// allow insert invalid index like others do
|
// allow insert invalid index like others do
|
||||||
if Index >= FStringList.Count then
|
if Index >= FStringList.Count then
|
||||||
Index := FStringList.Add(S)
|
begin
|
||||||
|
Index := FStringList.Add(S);
|
||||||
|
if FHasTrailingLineBreak then
|
||||||
|
W := UTF8ToUTF16(S + LineBreak)
|
||||||
else
|
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);
|
FStringList.Insert(Index, S);
|
||||||
W := {%H-}S;
|
W := UTF8ToUTF16(S);
|
||||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||||
|
end;
|
||||||
FTextChanged := False; // FStringList is already updated, no need to update from WS.
|
FTextChanged := False; // FStringList is already updated, no need to update from WS.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -426,6 +426,10 @@ end;
|
|||||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||||
var
|
var
|
||||||
W: WideString;
|
W: WideString;
|
||||||
|
ATextEdit: QTextEditH;
|
||||||
|
ADoc: QTextDocumentH;
|
||||||
|
ABlock: QTextBlockH;
|
||||||
|
ACursor: QTextCursorH;
|
||||||
begin
|
begin
|
||||||
if FTextChanged then InternalUpdate;
|
if FTextChanged then InternalUpdate;
|
||||||
if Index < 0 then Index := 0;
|
if Index < 0 then Index := 0;
|
||||||
@ -444,8 +448,18 @@ begin
|
|||||||
else
|
else
|
||||||
W := GetUTF8String(S);
|
W := GetUTF8String(S);
|
||||||
if FHasTrailingLineBreak then
|
if FHasTrailingLineBreak then
|
||||||
TQtTextEdit(FOwner.Handle).setLineText(Index, W)
|
begin
|
||||||
else
|
//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);
|
TQtTextEdit(FOwner.Handle).Append(W);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
|
@ -426,6 +426,10 @@ end;
|
|||||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||||
var
|
var
|
||||||
W: WideString;
|
W: WideString;
|
||||||
|
ATextEdit: QTextEditH;
|
||||||
|
ADoc: QTextDocumentH;
|
||||||
|
ABlock: QTextBlockH;
|
||||||
|
ACursor: QTextCursorH;
|
||||||
begin
|
begin
|
||||||
if FTextChanged then InternalUpdate;
|
if FTextChanged then InternalUpdate;
|
||||||
if Index < 0 then Index := 0;
|
if Index < 0 then Index := 0;
|
||||||
@ -444,8 +448,18 @@ begin
|
|||||||
else
|
else
|
||||||
W := GetUTF8String(S);
|
W := GetUTF8String(S);
|
||||||
if FHasTrailingLineBreak then
|
if FHasTrailingLineBreak then
|
||||||
TQtTextEdit(FOwner.Handle).setLineText(Index, W)
|
begin
|
||||||
else
|
//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);
|
TQtTextEdit(FOwner.Handle).Append(W);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user