Attempted fix of resizing issue in TOvcTable as a result of LCL 0.9.29 change in SetBounds behavior.

http://wiki.lazarus.freepascal.org/Lazarus_0.9.30_release_notes#overriding_TControl.SetBounds

Unknown how many other places where this or similar fixes will be needed; Orpheus overrides SetBounds throughout.

Also uncommented two place where Screen.DataModules was used as this now appears to be implemented in LCL.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1471 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
macpgmr
2011-01-29 23:51:20 +00:00
parent 304dbb2e2f
commit 2c37512236
4 changed files with 40 additions and 12 deletions

View File

@ -580,7 +580,11 @@ type
procedure CreateWnd; override; procedure CreateWnd; override;
procedure Loaded; override; procedure Loaded; override;
procedure Paint; override; procedure Paint; override;
{$IFNDEF LCL}
procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override; procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
{$ELSE}
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
{$ENDIF}
{new public methods} {new public methods}
function CalcRowColFromXY(X, Y : integer; function CalcRowColFromXY(X, Y : integer;
@ -3663,14 +3667,25 @@ procedure TOvcCustomTable.tbQueryRowData(RowNum : TRowNum;
end; end;
end; end;
{--------} {--------}
{$IFNDEF LCL}
procedure TOvcCustomTable.SetBounds(ALeft, ATop, AWidth, AHeight: integer); procedure TOvcCustomTable.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
{$ELSE}
procedure TOvcCustomTable.DoSetBounds(ALeft, ATop, AWidth, AHeight: integer);
{$ENDIF}
// LCL port: Behavior of SetBounds changed in 0.9.29, so using DoSetBounds.
// http://wiki.lazarus.freepascal.org/Lazarus_0.9.30_release_notes#overriding_TControl.SetBounds
// Calls to TOvcTable.SetBounds will just be handled by ancestor.
var var
WidthChanged : boolean; WidthChanged : boolean;
HeightChanged : boolean; HeightChanged : boolean;
begin begin
if (not HandleAllocated) then if (not HandleAllocated) then
begin begin
{$IFNDEF LCL}
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
{$ELSE}
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
{$ENDIF}
Exit; Exit;
end; end;
@ -3681,7 +3696,11 @@ procedure TOvcCustomTable.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
begin begin
AllowRedraw := false; AllowRedraw := false;
try try
{$IFNDEF LCL}
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
{$ELSE}
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
{$ENDIF}
if WidthChanged then if WidthChanged then
tbCalcColData(tbColNums, LeftCol); tbCalcColData(tbColNums, LeftCol);
if HeightChanged then if HeightChanged then
@ -3698,7 +3717,11 @@ procedure TOvcCustomTable.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
end;{try..finally} end;{try..finally}
end end
else else
{$IFNDEF LCL}
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
{$ELSE}
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
{$ENDIF}
end; end;
{====================================================================} {====================================================================}

View File

@ -577,15 +577,15 @@ procedure TOvcTableColumns.tcStopLoading;
{fixup references to cell components on any data modules} {fixup references to cell components on any data modules}
if (FFixups.Count <> 0) then begin if (FFixups.Count <> 0) then begin
DM := 0; DM := 0;
{$IFNDEF LCL} //{$IFNDEF LCL}
DMCount := Screen.DataModuleCount; DMCount := Screen.DataModuleCount;
{$ELSE} //{$ELSE}
DMCount := 0; // DMCount := 0;
{$ENDIF} //{$ENDIF}
while (FFixups.Count > 0) and (DM < DMCount) do begin while (FFixups.Count > 0) and (DM < DMCount) do begin
{$IFNDEF LCL} //{$IFNDEF LCL}
DataMod := Screen.DataModules[DM]; DataMod := Screen.DataModules[DM];
{$ENDIF} //{$ENDIF}
for i := pred(FFixups.Count) downto 0 do for i := pred(FFixups.Count) downto 0 do
if (GetFormName(FFixups[i], Form.Name) = DataMod.Name) then begin if (GetFormName(FFixups[i], Form.Name) = DataMod.Name) then begin
Compnt := DataMod.FindComponent(GetComponentName(FFixups[i])); Compnt := DataMod.FindComponent(GetComponentName(FFixups[i]));

View File

@ -426,6 +426,9 @@ procedure TOvcBaseTableCell.tcChangeScale(M, D : integer);
{--------} {--------}
procedure TOvcBaseTableCell.DecRefs; procedure TOvcBaseTableCell.DecRefs;
begin begin
//try // LCL: On Carbon, get "EXC_BAD_ACCESS, Could not access memory" for
// FReferences when free cell's column (for example, when quit app),
// as though cell object's memory already freed, so trap and ignore.
if (FReferences > 0) then if (FReferences > 0) then
begin begin
dec(FReferences); dec(FReferences);
@ -436,6 +439,8 @@ procedure TOvcBaseTableCell.DecRefs;
FOnCfgChanged := nil; FOnCfgChanged := nil;
end; end;
end; end;
//except
//end;
end; end;
{--------} {--------}
function TOvcBaseTableCell.DoOwnerDraw(TableCanvas : TCanvas; function TOvcBaseTableCell.DoOwnerDraw(TableCanvas : TCanvas;

View File

@ -715,16 +715,16 @@ begin
if (taLoadList.Count <> 0) then if (taLoadList.Count <> 0) then
begin begin
DM := 0; DM := 0;
{$IFNDEF LCL} //{$IFNDEF LCL}
DMCount := Screen.DataModuleCount; DMCount := Screen.DataModuleCount;
{$ELSE} //{$ELSE}
DMCount := 0; // DMCount := 0;
{$ENDIF} //{$ENDIF}
while (taLoadList.Count > 0) and (DM < DMCount) do while (taLoadList.Count > 0) and (DM < DMCount) do
begin begin
{$IFNDEF LCL} //{$IFNDEF LCL}
DataMod := Screen.DataModules[DM]; DataMod := Screen.DataModules[DM];
{$ENDIF} //{$ENDIF}
for i := pred(taLoadList.Count) downto 0 do for i := pred(taLoadList.Count) downto 0 do
if (GetFormName(taLoadList[i], Form.Name) = DataMod.Name) then if (GetFormName(taLoadList[i], Form.Name) = DataMod.Name) then
begin begin