LCL: introduced TWSScrollBar.SetKind() to avoid usage of RecreateWnd when changing kind of TScrollBar, because it crashes on 64bit installations.Fixed AV with qt and gtk2 under 64bit

git-svn-id: trunk@30853 -
This commit is contained in:
zeljko 2011-05-22 09:53:34 +00:00
parent 158cde9b63
commit 01f454abce
5 changed files with 74 additions and 6 deletions

View File

@ -86,14 +86,13 @@ begin
OldHeight:=Height;
Constraints.UpdateInterfaceConstraints;
// TODO: Remove RecreateWnd
if HandleAllocated
then RecreateWnd(Self);
// switch width and height, but not when loading, because we assume that
// the lfm contains a consistent combination of kind and (width, height)
if (csLoading in ComponentState) then Exit;
if HandleAllocated then
TWSScrollBarClass(WidgetSetClass).SetKind(Self, FKind = sbHorizontal);
SetBounds(Left,Top,OldHeight,OldWidth);
end;

View File

@ -379,14 +379,19 @@ end;
class procedure TGtk2WSTrackBar.SetOrientation(
const ATrackBar: TCustomTrackBar; const AOrientation: TTrackBarOrientation);
var
B: Boolean;
begin
if not WSCheckHandleAllocated(ATrackBar, 'SetOrientation') then
Exit;
ATrackBar.Hide;
B := ATrackBar.Visible;
if B then
ATrackBar.Hide;
try
RecreateWnd(ATrackBar);
finally
ATrackBar.Show;
if B then
ATrackBar.Show;
end;
end;

View File

@ -73,6 +73,7 @@ type
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetKind(const AScrollBar: TCustomScrollBar; const AIsHorizontal: Boolean); override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
end;
@ -2440,6 +2441,24 @@ begin
SetCallbacks(Widget, WidgetInfo);
end;
class procedure TGtk2WSScrollBar.SetKind(const AScrollBar: TCustomScrollBar;
const AIsHorizontal: Boolean);
var
B: Boolean;
begin
if not AScrollBar.HandleAllocated then
exit;
B := AScrollBar.Visible;
if B then
AScrollBar.Hide;
try
RecreateWnd(AScrollBar);
finally
if B then
AScrollBar.Show;
end;
end;
class procedure TGtk2WSScrollBar.SetParams(const AScrollBar: TCustomScrollBar);
var
Range: PGtkRange;

View File

@ -47,6 +47,7 @@ type
published
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetKind(const AScrollBar: TCustomScrollBar; const AIsHorizontal: Boolean); override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
end;
@ -314,6 +315,41 @@ begin
Result := TLCLIntfHandle(QtScrollbar);
end;
class procedure TQtWSScrollBar.SetKind(const AScrollBar: TCustomScrollBar;
const AIsHorizontal: Boolean);
var
QtScrollBar: TQtScrollBar;
begin
if not WSCheckHandleAllocated(AScrollBar, 'SetKind') then
Exit;
QtScrollBar := TQtScrollBar(AScrollBar.Handle);
QtScrollBar.BeginUpdate;
try
case AScrollBar.Kind of
sbHorizontal:
begin
if QtScrollBar.getOrientation <> QtHorizontal then
QtScrollBar.SetOrientation(QtHorizontal);
if QtScrollBar.getInvertedAppereance then
QtScrollBar.setInvertedAppereance(False);
if QtScrollbar.getInvertedControls then
QtScrollBar.setInvertedControls(False);
end;
sbVertical:
begin
if QtScrollBar.getOrientation <> QtVertical then
QtScrollBar.SetOrientation(QtVertical);
if QtScrollBar.getInvertedAppereance then
QtScrollBar.setInvertedAppereance(False);
if not QtScrollbar.getInvertedControls then
QtScrollBar.setInvertedControls(True);
end;
end;
finally
QtScrollbar.EndUpdate;
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomScrollBar.SetParams
Params: None
@ -323,6 +359,8 @@ class procedure TQtWSScrollBar.SetParams(const AScrollBar: TCustomScrollBar);
var
QtScrollBar: TQtScrollBar;
begin
if not WSCheckHandleAllocated(AScrollBar, 'SetParams') then
Exit;
QtScrollBar := TQtScrollBar(AScrollBar.Handle);
QtScrollBar.BeginUpdate;

View File

@ -54,6 +54,7 @@ type
TWSScrollBar = class(TWSWinControl)
published
class procedure SetParams(const AScrollBar: TCustomScrollBar); virtual;
class procedure SetKind(const AScrollBar: TCustomScrollBar; const AIsHorizontal: Boolean); virtual;
end;
TWSScrollBarClass = class of TWSScrollBar;
@ -278,6 +279,12 @@ class procedure TWSScrollBar.SetParams(const AScrollBar: TCustomScrollBar);
begin
end;
class procedure TWSScrollBar.SetKind(const AScrollBar: TCustomScrollBar;
const AIsHorizontal: Boolean);
begin
RecreateWnd(AScrollBar);
end;
{ TWSCustomListBox }
class function TWSCustomListBox.GetIndexAtXY(