mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 13:20:18 +02:00
LCL: Prevent a crash when getting editor for an empty Grid. Issue #32623, patch from C Western.
git-svn-id: trunk@56235 -
This commit is contained in:
parent
7a60c60d61
commit
8de5a73097
@ -1258,6 +1258,7 @@ type
|
|||||||
procedure AutoAdjustColumns; virtual;
|
procedure AutoAdjustColumns; virtual;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
function CellRect(ACol, ARow: Integer): TRect;
|
function CellRect(ACol, ARow: Integer): TRect;
|
||||||
|
function CellRectValid(ACol, ARow: Integer; out ARect: TRect): Boolean;
|
||||||
function CellToGridZone(aCol,aRow: Integer): TGridZone;
|
function CellToGridZone(aCol,aRow: Integer): TGridZone;
|
||||||
procedure CheckPosition;
|
procedure CheckPosition;
|
||||||
function ClearCols: Boolean;
|
function ClearCols: Boolean;
|
||||||
@ -3421,12 +3422,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Returns a reactagle corresponding to a fisical cell[aCol,aRow] }
|
{ Returns a reactagle corresponding to a physical cell[aCol,aRow] }
|
||||||
function TCustomGrid.CellRect(ACol, ARow: Integer): TRect;
|
function TCustomGrid.CellRect(ACol, ARow: Integer): TRect;
|
||||||
begin
|
begin
|
||||||
//Result:=ColRowToClientCellRect(aCol,aRow);
|
Assert( (ACol<ColCount) and (ARow<RowCount),
|
||||||
ColRowToOffset(True, True, ACol, Result.Left, Result.Right);
|
Format('TCustomGrid.CellRect: ACol (%d) or ARow (%d) out of range.',[ACol,ARow]) );
|
||||||
ColRowToOffSet(False,True, ARow, Result.Top, Result.Bottom);
|
CellRectValid(ACol, ARow, Result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomGrid.CellRectValid(ACol, ARow: Integer; out ARect: TRect): Boolean;
|
||||||
|
begin
|
||||||
|
Result := ColRowToOffset(True, True, ACol, ARect.Left, ARect.Right)
|
||||||
|
and ColRowToOffSet(False,True, ARow, ARect.Top, ARect.Bottom);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// The visible grid Depends on TopLeft and ClientWidht,ClientHeight,
|
// The visible grid Depends on TopLeft and ClientWidht,ClientHeight,
|
||||||
@ -8207,6 +8214,7 @@ procedure TCustomGrid.EditorPos;
|
|||||||
var
|
var
|
||||||
msg: TGridMessage;
|
msg: TGridMessage;
|
||||||
CellR: TRect;
|
CellR: TRect;
|
||||||
|
PosValid: Boolean;
|
||||||
begin
|
begin
|
||||||
{$ifdef dbgGrid} DebugLn('Grid.EditorPos INIT');{$endif}
|
{$ifdef dbgGrid} DebugLn('Grid.EditorPos INIT');{$endif}
|
||||||
if HandleAllocated and (FEditor<>nil) then begin
|
if HandleAllocated and (FEditor<>nil) then begin
|
||||||
@ -8219,9 +8227,11 @@ begin
|
|||||||
FEditor.Dispatch(Msg);
|
FEditor.Dispatch(Msg);
|
||||||
|
|
||||||
// send editor bounds
|
// send editor bounds
|
||||||
CellR:=CellRect(FCol,FRow);
|
PosValid := CellRectValid(FCol, FRow, CellR);
|
||||||
|
if not PosValid then // Can't position editor; ensure sane values
|
||||||
|
CellR := Rect(0,0,FEditor.Width, FEditor.Height);
|
||||||
|
|
||||||
if (CellR.Top<FGCache.FixedHeight) or (CellR.Top>FGCache.ClientHeight) or
|
if not PosValid or (CellR.Top<FGCache.FixedHeight) or (CellR.Top>FGCache.ClientHeight) or
|
||||||
(UseRightToLeftAlignment and ((CellR.Right-1>FlipX(FGCache.FixedWidth)) or (CellR.Right<0))) or
|
(UseRightToLeftAlignment and ((CellR.Right-1>FlipX(FGCache.FixedWidth)) or (CellR.Right<0))) or
|
||||||
(not UseRightToLeftAlignment and ((CellR.Left<FGCache.FixedWidth) or (CellR.Left>FGCache.ClientWidth)))
|
(not UseRightToLeftAlignment and ((CellR.Left<FGCache.FixedWidth) or (CellR.Left>FGCache.ClientWidth)))
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user