NiceGrid: Fix crash in gtk3 due to loading cursors. Introduce TNiceGridState to avoid defining the grid state by means of the current cursor.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8870 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2023-06-30 21:18:38 +00:00
parent 792ce273a7
commit e44baffbcc
2 changed files with 77 additions and 69 deletions

View File

@ -42,7 +42,7 @@
<Filename Value="basic_demo.lpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="47" Y="15"/>
<UsageCount Value="31"/>
<UsageCount Value="35"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -69,7 +69,7 @@
<EditorIndex Value="5"/>
<TopLine Value="2446"/>
<CursorPos X="15" Y="2463"/>
<UsageCount Value="12"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -101,9 +101,9 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
<EditorIndex Value="1"/>
<TopLine Value="18"/>
<CursorPos X="7" Y="35"/>
<UsageCount Value="29"/>
<TopLine Value="121"/>
<CursorPos X="3" Y="126"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit7>
@ -112,9 +112,9 @@
<UnitName Value="NiceGrid"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
<TopLine Value="307"/>
<CursorPos X="52" Y="323"/>
<UsageCount Value="12"/>
<TopLine Value="551"/>
<CursorPos X="14" Y="573"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
@ -122,7 +122,7 @@
<EditorIndex Value="2"/>
<TopLine Value="740"/>
<CursorPos Y="771"/>
<UsageCount Value="12"/>
<UsageCount Value="14"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
@ -130,7 +130,7 @@
<EditorIndex Value="7"/>
<TopLine Value="287"/>
<CursorPos X="10" Y="305"/>
<UsageCount Value="10"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
@ -139,7 +139,7 @@
<EditorIndex Value="6"/>
<TopLine Value="1202"/>
<CursorPos X="3" Y="1220"/>
<UsageCount Value="10"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
@ -148,7 +148,7 @@
<EditorIndex Value="4"/>
<TopLine Value="46"/>
<CursorPos X="14" Y="64"/>
<UsageCount Value="10"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
@ -157,130 +157,130 @@
<EditorIndex Value="8"/>
<TopLine Value="317"/>
<CursorPos X="10" Y="335"/>
<UsageCount Value="10"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit13>
</Units>
<JumpHistory Count="30" HistoryIndex="28">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="701" Column="11" TopLine="678"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="522" Column="35" TopLine="504"/>
</Position1>
<Position2>
<Filename Value="..\common\main.pas"/>
<Caret Line="35" Column="7" TopLine="18"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3698" Column="3" TopLine="3680"/>
</Position2>
<Position3>
<Filename Value="..\..\..\source\nicegridreg.pas"/>
<Caret Line="63" Column="9" TopLine="48"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3708" Column="58" TopLine="3691"/>
</Position3>
<Position4>
<Filename Value="..\..\..\source\nicegridreg.pas"/>
<Caret Line="64" Column="14" TopLine="46"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3681" Column="36" TopLine="3663"/>
</Position4>
<Position5>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="519" Column="43" TopLine="501"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="290" Column="30" TopLine="274"/>
</Position5>
<Position6>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="3711" Column="57" TopLine="3693"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1300" Column="57" TopLine="1283"/>
</Position6>
<Position7>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="3684" Column="36" TopLine="3666"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1251" Column="57" TopLine="1226"/>
</Position7>
<Position8>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="290" Column="30" TopLine="274"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1232" Column="59" TopLine="1213"/>
</Position8>
<Position9>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="1505" Column="21" TopLine="1483"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1212" Column="59" TopLine="1194"/>
</Position9>
<Position10>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="1306" Column="74" TopLine="1292"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1156" Column="16" TopLine="1144"/>
</Position10>
<Position11>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="2786" Column="13" TopLine="2745"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="699" Column="11" TopLine="677"/>
</Position11>
<Position12>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="2696" Column="30" TopLine="2683"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="323" Column="52" TopLine="307"/>
</Position12>
<Position13>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="353" Column="15" TopLine="336"/>
<Filename Value="..\common\main.pas"/>
<Caret Line="35" Column="7" TopLine="17"/>
</Position13>
<Position14>
<Filename Value="..\..\..\source\NiceGrid.pas"/>
<Caret Line="415" Column="13" TopLine="412"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="415" Column="25" TopLine="396"/>
</Position14>
<Position15>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="642" Column="50" TopLine="625"/>
<Caret Line="643" Column="36" TopLine="625"/>
</Position15>
<Position16>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="563" Column="28" TopLine="534"/>
<Caret Line="640" Column="8" TopLine="630"/>
</Position16>
<Position17>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3708" Column="29" TopLine="3680"/>
<Caret Line="557" Column="88" TopLine="536"/>
</Position17>
<Position18>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="522" Column="35" TopLine="504"/>
<Filename Value="..\common\main.pas"/>
<Caret Line="35" Column="35" TopLine="18"/>
</Position18>
<Position19>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3698" Column="3" TopLine="3680"/>
<Filename Value="..\common\main.pas"/>
<Caret Line="126" Column="3" TopLine="121"/>
</Position19>
<Position20>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3708" Column="58" TopLine="3691"/>
<Caret Line="290" Column="30" TopLine="274"/>
</Position20>
<Position21>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="3681" Column="36" TopLine="3663"/>
<Caret Line="3175" Column="15" TopLine="3171"/>
</Position21>
<Position22>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="290" Column="30" TopLine="274"/>
<Caret Line="522" Column="35" TopLine="504"/>
</Position22>
<Position23>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1300" Column="57" TopLine="1283"/>
<Caret Line="4180" Column="16" TopLine="4178"/>
</Position23>
<Position24>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1251" Column="57" TopLine="1226"/>
<Caret Line="523" Column="33" TopLine="505"/>
</Position24>
<Position25>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1232" Column="59" TopLine="1213"/>
<Caret Line="4191" Column="36" TopLine="4188"/>
</Position25>
<Position26>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1212" Column="59" TopLine="1194"/>
<Caret Line="575" Column="5" TopLine="551"/>
</Position26>
<Position27>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="1156" Column="16" TopLine="1144"/>
<Caret Line="523" Column="46" TopLine="505"/>
</Position27>
<Position28>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="699" Column="11" TopLine="677"/>
<Caret Line="519" Column="43" TopLine="501"/>
</Position28>
<Position29>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="323" Column="15" TopLine="307"/>
<Caret Line="4203" Column="16" TopLine="4201"/>
</Position29>
<Position30>
<Filename Value="C:\Lazarus\lazarus-main_fpc3.2.2\lcl\controls.pp"/>
<Caret Line="2463" Column="15" TopLine="2446"/>
<Filename Value="..\..\..\source\nicegrid.pas"/>
<Caret Line="4195" Column="3" TopLine="4177"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -554,7 +554,7 @@ const
CursorArray: array [TGridHitTest] of TCursor =
//(gtNone, gtLeftTop, gtLeft, gtTop, gtCell, gtColSizing, gtSmallBox);
{$IFDEF LCLGtk3}
{$IFDEF LCLGtk3} // Issue with loading cursors in GTK3 --> use predefined cursors.
(crDefault, crSizeSE, crSizeE, crSizeS, crHandPoint, crHSplit, crCross);
{$ELSE}
(crDefault, crLeftTop, crRight, crDown, crPlus, crHSplit, crSmallCross);
@ -565,6 +565,15 @@ const
MergeID = -2;
{$HINTS OFF}
procedure Unused(const A1); overload;
begin
end;
procedure Unused(const A1, A2); overload;
begin
end;
{$HINTS ON}
{ TNiceGrid }
@ -638,13 +647,8 @@ begin
SmallBoxPos := 0;
SizingCol := -1;
SizingColX := -1;
{$IFDEF LCLGtk3}
Screen.Cursors[crPlus] := Screen.Cursors[crHandPoint];
Screen.Cursors[crSmallCross] := Screen.Cursors[crCross];
Screen.Cursors[crRight] := Screen.Cursors[crSizeE];
Screen.Cursors[crDown] := Screen.Cursors[crSizeS];
Screen.Cursors[crLeftTop] := Screen.Cursors[crSizeSE];
{$ELSE}
{$IFNDEF LCLGtk3} // Issue with loading cursors in GTK3.
Screen.Cursors[crPlus] := LoadCursor(hinstance, 'CR_PLUS');
Screen.Cursors[crSmallCross] := LoadCursor(hInstance, 'CR_CROSS');
Screen.Cursors[crRight] := LoadCursor(hinstance, 'CR_RIGHT');
@ -3172,6 +3176,7 @@ end;
procedure TNiceGrid.WMSetFocus(var Msg: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF});
begin
Unused(Msg);
CreateCaret(Handle, 0, 1, FDefRowHeight - 2);
CaretVisible := False;
InvalidateCells;
@ -4176,6 +4181,7 @@ end;
procedure TNiceGridSync.SetScrollBar(AKind, AMax, APos, AMask: Integer);
begin
Unused(AMax);
if (AKind = SB_VERT) and Assigned(FGrid) then
begin
if ((AMask and SIF_POS) <> 0)
@ -4186,6 +4192,7 @@ end;
procedure TNiceGridSync.ShowHideScrollBar(HorzVisible,
VertVisible: Boolean);
begin
Unused(HorzVisible, VertVisible);
ShowScrollBar(Handle, SB_HORZ, True);
ShowScrollBar(Handle, SB_VERT, False);
EnableScrollBar(Handle, SB_HORZ, 3{ESB_DISABLE_BOTH});
@ -4193,6 +4200,7 @@ end;
procedure TNiceGridSync.SyncColRow(Sender: TObject; ACol, ARow: Integer);
begin
Unused(ACol);
if Assigned(FGrid)
then FGrid.Row := ARow;
end;