Qt,Qt5,Qt6: fixed error with sorted TQtComboStrings. issue #40353

(cherry picked from commit dcf14bec5a)
This commit is contained in:
Željan Rikalo 2023-06-28 10:17:16 +02:00 committed by Maxim Ganetsky
parent 37e1398b1c
commit 21f35c1381
3 changed files with 27 additions and 21 deletions

View File

@ -566,15 +566,17 @@ begin
end; end;
function TQtComboStrings.Add(const S: String): Integer; function TQtComboStrings.Add(const S: String): Integer;
var
I: Integer;
begin begin
if FSorted then Result := inherited Add(S);
if FSorted and Assigned(FWinControl) and (FWinControl.HandleAllocated) then
begin begin
Find(S, Result); FOwner.BeginUpdate;
FChanging := True; for I := 0 to Count - 1 do
Insert(Result, S); FOwner.setItemText(I, Strings[I]);
FChanging := False; FOwner.EndUpdate;
end else end;
Result := inherited Add(S);
end; end;
procedure TQtComboStrings.Assign(Source: TPersistent); procedure TQtComboStrings.Assign(Source: TPersistent);

View File

@ -570,15 +570,17 @@ begin
end; end;
function TQtComboStrings.Add(const S: String): Integer; function TQtComboStrings.Add(const S: String): Integer;
var
I: Integer;
begin begin
if FSorted then Result := inherited Add(S);
if FSorted and Assigned(FWinControl) and (FWinControl.HandleAllocated) then
begin begin
Find(S, Result); FOwner.BeginUpdate;
FChanging := True; for I := 0 to Count - 1 do
Insert(Result, S); FOwner.setItemText(I, Strings[I]);
FChanging := False; FOwner.EndUpdate;
end else end;
Result := inherited Add(S);
end; end;
procedure TQtComboStrings.Assign(Source: TPersistent); procedure TQtComboStrings.Assign(Source: TPersistent);

View File

@ -570,15 +570,17 @@ begin
end; end;
function TQtComboStrings.Add(const S: String): Integer; function TQtComboStrings.Add(const S: String): Integer;
var
I: Integer;
begin begin
if FSorted then Result := inherited Add(S);
if FSorted and Assigned(FWinControl) and (FWinControl.HandleAllocated) then
begin begin
Find(S, Result); FOwner.BeginUpdate;
FChanging := True; for I := 0 to Count - 1 do
Insert(Result, S); FOwner.setItemText(I, Strings[I]);
FChanging := False; FOwner.EndUpdate;
end else end;
Result := inherited Add(S);
end; end;
procedure TQtComboStrings.Assign(Source: TPersistent); procedure TQtComboStrings.Assign(Source: TPersistent);