From 97b7e5c8efa5047ce22b65ca0ff0dda41efe67fc Mon Sep 17 00:00:00 2001 From: zeljko Date: Sun, 18 Dec 2011 11:12:40 +0000 Subject: [PATCH] Qt: fixed seg fault with TCheckListBox, fixed passing OnItemClick when adding items.issue #20927 git-svn-id: trunk@34254 - --- lcl/interfaces/qt/qtprivate.pp | 12 ++++++++++++ lcl/interfaces/qt/qtwidgets.pas | 2 ++ 2 files changed, 14 insertions(+) diff --git a/lcl/interfaces/qt/qtprivate.pp b/lcl/interfaces/qt/qtprivate.pp index 2040344b4e..445d36983a 100644 --- a/lcl/interfaces/qt/qtprivate.pp +++ b/lcl/interfaces/qt/qtprivate.pp @@ -564,6 +564,7 @@ begin inherited Put(Index, S); if Assigned(FWinControl) and (FWinControl.HandleAllocated) then begin + FOwner.BeginUpdate; FOwner.setItemText(Index, S); if FOwner is TQtCheckListBox then begin @@ -573,6 +574,7 @@ begin else FOwner.ItemFlags[Index] := FOwner.ItemFlags[Index] and not QtItemIsTristate; end; + FOwner.EndUpdate; end; end; @@ -581,6 +583,7 @@ begin inherited InsertItem(Index, S); if Assigned(FWinControl) and (FWinControl.HandleAllocated) then begin + FOwner.BeginUpdate; FOwner.insertItem(Index, S); if FOwner is TQtCheckListBox then begin @@ -590,6 +593,7 @@ begin else FOwner.ItemFlags[Index] := FOwner.ItemFlags[Index] and not QtItemIsTristate; end; + FOwner.EndUpdate; end; end; @@ -598,6 +602,7 @@ begin inherited InsertItem(Index, S, O); if Assigned(FWinControl) and (FWinControl.HandleAllocated) then begin + FOwner.BeginUpdate; FOwner.insertItem(Index, S); if FOwner is TQtCheckListBox then @@ -608,6 +613,7 @@ begin else FOwner.ItemFlags[Index] := FOwner.ItemFlags[Index] and not QtItemIsTristate; end; + FOwner.EndUpdate; end; end; @@ -658,7 +664,11 @@ procedure TQtListStrings.Delete(Index: Integer); begin inherited Delete(Index); if Assigned(FWinControl) and (FWinControl.HandleAllocated) then + begin + FOwner.BeginUpdate; FOwner.removeItem(Index); + FOwner.EndUpdate; + end; end; procedure TQtListStrings.Move(CurIndex, NewIndex: Integer); @@ -695,8 +705,10 @@ begin inherited Sort; if Assigned(FWinControl) and (FWinControl.HandleAllocated) then begin + FOwner.BeginUpdate; for I := 0 to Count - 1 do FOwner.setItemText(I, Strings[I]); + FOwner.EndUpdate; end; end; diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index cd92764aaf..d721514b77 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -10758,6 +10758,8 @@ var APos: TQtPoint; AMouseEvent: QMouseEventH; begin + if InUpdate or not GetVisible then + exit; // fires only when checkBox clicked. QCursor_pos(@AGlobalPos); QWidget_mapFromGlobal(Widget, @APos, @AGlobalPos);