From 882516cfb11bc7a6378b49a5cb3d86c73d11a017 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 13 Sep 2012 09:42:10 +0000 Subject: [PATCH] LCL: gtk2: fixed access to private variables of TWinControl git-svn-id: trunk@38638 - --- ide/ideguicmdline.pas | 13 +++++++++---- lcl/interfaces/gtk2/gtk2wsbuttons.pp | 15 ++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ide/ideguicmdline.pas b/ide/ideguicmdline.pas index 1955681bb7..a55868a864 100644 --- a/ide/ideguicmdline.pas +++ b/ide/ideguicmdline.pas @@ -29,6 +29,9 @@ This unit manages the command line parameters for lazarus and startlazarus, but not lazbuild. + + ToDo: + Linux: try pidof } unit IDEGuiCmdLine; @@ -41,10 +44,10 @@ uses LazarusIDEStrConsts, IDECmdLine; procedure ParseGuiCmdLineParams(var SkipAutoLoadingLastProject, - StartedByStartLazarus, - EnableRemoteControl, - ShowSplashScreen, - Setup: Boolean); + StartedByStartLazarus, + EnableRemoteControl, + ShowSplashScreen, + Setup: Boolean); // remote control const @@ -74,6 +77,7 @@ uses MacOSAll, CarbonProc; function IsLazarusPIDRunning(aPID: int64): boolean; + {$IFDEF UseProcFileSystem} function CheckProcFileSystem: boolean; var sl: TStringList; @@ -95,6 +99,7 @@ function IsLazarusPIDRunning(aPID: int64): boolean; sl.Free; end; end; + {$ENDIF} {$IFDEF UseFreeBSDKernProc} function CheckFreeBSDKernProc: boolean; diff --git a/lcl/interfaces/gtk2/gtk2wsbuttons.pp b/lcl/interfaces/gtk2/gtk2wsbuttons.pp index d7d5828c3f..3530f0bb30 100644 --- a/lcl/interfaces/gtk2/gtk2wsbuttons.pp +++ b/lcl/interfaces/gtk2/gtk2wsbuttons.pp @@ -38,6 +38,7 @@ type TBitBtnWidgetInfo = record ImageWidget: Pointer; LabelWidget: Pointer; + SetLayoutCalled: boolean; end; { TGtk2WSBitBtn } @@ -95,9 +96,6 @@ type TCustomBitBtnAccess = class(TCustomBitBtn) end; - TWinControlAccess = class(TWinControl) - end; - procedure GtkWSBitBtn_StateChanged(AWidget: PGtkWidget; {%H-}AState: TGtkStateType; AInfo: PWidgetInfo); cdecl; var BitBtn: TCustomBitBtnAccess; @@ -233,8 +231,7 @@ begin WidgetInfo := GetWidgetInfo(MainWidget); BitBtnInfo := WidgetInfo^.UserData; BuildNeeded := UpdateGlyph(ABitBtn, BitBtnInfo, AValue, GtkStateToButtonState[GTK_WIDGET_STATE(MainWidget)]); - // at initialization widget will be built in SetLayout - if not (wcfInitializing in {%H-}TWinControlAccess(ABitBtn).FWinControlFlags) and BuildNeeded then + if BuildNeeded and BitBtnInfo^.SetLayoutCalled then BuildWidget(ABitBtn, MainWidget, BitBtnInfo, ABitBtn.Caption); end; @@ -250,6 +247,7 @@ begin MainWidget := {%H-}Pointer(ABitBtn.Handle); WidgetInfo := GetWidgetInfo(MainWidget); BitBtnInfo := WidgetInfo^.UserData; + BitBtnInfo^.SetLayoutCalled:=true; BuildWidget(ABitBtn, MainWidget, BitBtnInfo, ABitBtn.Caption); end; @@ -294,13 +292,12 @@ var BitBtnInfo: PBitBtnWidgetInfo; BuildNeeded: Boolean; begin - // at initialization widget will be built in SetLayout - if (wcfInitializing in TWinControlAccess(AWinControl).FWinControlFlags) - or not WSCheckHandleAllocated(AWincontrol, 'SetText') then - Exit; MainWidget := {%H-}Pointer(AWinControl.Handle); WidgetInfo := GetWidgetInfo(MainWidget); BitBtnInfo := WidgetInfo^.UserData; + if (not BitBtnInfo^.SetLayoutCalled) + or not WSCheckHandleAllocated(AWincontrol, 'SetText') then + Exit; LabelWidget := BitBtnInfo^.LabelWidget; BuildNeeded := (LabelWidget = nil) xor (AText = ''); if BuildNeeded then