Skip to content

Commit

Permalink
Handle some nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Richardson committed Apr 15, 2024
1 parent 5453569 commit 8ddba71
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Eto.Gtk/Forms/Controls/GridHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ protected override void Initialize()
if (!AllowEmptySelection && AllowMultipleSelection && Control.Selection.CountSelectedRows() == 0)
{
Control.GetCursor(out var cursorRow, out _);
Control.Selection.SelectPath(cursorRow);
if (cursorRow != null)
{
Control.Selection.SelectPath(cursorRow);
}
}
};

Expand Down Expand Up @@ -737,11 +740,12 @@ private void SetSelectionMode(bool allowEmptySelection, bool allowMultipleSelect
&& newMode is Gtk.SelectionMode.Single or Gtk.SelectionMode.Browse)
{
Control.GetCursor(out var cursorRowPath, out _);
var cursorWasSelected = Control.Selection.PathIsSelected(cursorRowPath);
var mustReselectCursor = cursorRowPath != null && Control.Selection.PathIsSelected(cursorRowPath);

Control.Selection.Mode = Gtk.SelectionMode.None;
Control.Selection.Mode = newMode;
if (cursorWasSelected)

if (mustReselectCursor)
{
Control.Selection.SelectPath(cursorRowPath);
}
Expand Down

0 comments on commit 8ddba71

Please sign in to comment.