GridView crash on mac

Dear Rhino developers,

I am working on eto panel, and I have encountered a problem where it crashes on mac. On windows its working fine.

For presentation of problem as a base I have used this example by @dale:

I have changed code as below to update GridView values by clicking on hello:

using System;
using Eto.Drawing;
using Eto.Forms;
using Rhino.UI;

namespace SampleCsEto.Views
{
  /// <summary>
  /// Required class GUID, used as the panel Id
  /// </summary>
  [System.Runtime.InteropServices.Guid("0E7780CA-F004-4AE7-B918-19E68BF7C7C9")]
  public class SampleCsEtoPanel : Panel, IPanel
  {
    /// <summary>
    /// Provide easy access to the SampleCsEtoPanel.GUID
    /// </summary>
    public static System.Guid PanelId => typeof(SampleCsEtoPanel).GUID;

    public GridView MyGridView = new GridView { ShowHeader = false, AllowColumnReordering = false, AllowEmptySelection = true, GridLines = GridLines.Vertical };

    /// <summary>
    /// Required public constructor with NO parameters
    /// </summary>
    public SampleCsEtoPanel(uint documentSerialNumber)
    {
      m_document_sn = documentSerialNumber;

      Title = GetType().Name;

      var myGridColumn1 = new GridColumn();
      myGridColumn1.DataCell = new TextBoxCell(0);
      myGridColumn1.Width = 32;
      var myGridColumn2 = new GridColumn();
      myGridColumn2.DataCell = new TextBoxCell(1);
      myGridColumn2.Width = 53;
      var myGridColumn3 = new GridColumn();
      myGridColumn3.DataCell = new TextBoxCell(2);
      myGridColumn3.Width = 40;
      MyGridView.Columns.Add(myGridColumn1);
      MyGridView.Columns.Add(myGridColumn2);
      MyGridView.Columns.Add(myGridColumn3);
      MyGridView.DataStore = new string[][]
      {
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
           new string[] { "test", "test1", "t3" },
      };


      var hello_button = new Button { Text = "Hello..." };
      hello_button.Click += (sender, e) => OnHelloButton();

      var child_button = new Button { Text = "Child Dialog..." };
      child_button.Click += (sender, e) => OnChildButton();

      var document_sn_label = new Label() { Text = $"Document serial number: {documentSerialNumber}" };

      var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10), Width = 260 };
      layout.AddSeparateRow(hello_button, null);
      layout.AddSeparateRow(child_button, null);
      layout.AddSeparateRow(document_sn_label, null);
      layout.BeginGroup("test");
      layout.AddSeparateRow(MyGridView, null);
      layout.EndGroup();
      layout.Add(null);

      var scrollableLayout = new DynamicLayout();
      scrollableLayout.BeginScrollable(BorderType.None);
      scrollableLayout.AddCentered(layout, null, null, null, null, true, false);
      scrollableLayout.EndScrollable();

      Content = scrollableLayout;
    }

    private readonly uint m_document_sn;

    public string Title { get; }

    /// <summary>
    /// Example of proper way to display a message box
    /// </summary>
    protected void OnHelloButton()
    {
      // Use the Rhino common message box and NOT the Eto MessageBox,
      // the Eto version expects a top level Eto Window as the owner for
      // the MessageBox and will cause problems when running on the Mac.
      // Since this panel is a child of some Rhino container it does not
      // have a top level Eto Window.
      Dialogs.ShowMessage("Hello Rhino!", Title);
      
      MyGridView.DataStore = new string[][]
      {
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
           new string[] { "hello", "hello1", "h3" },
      };
    }

    /// <summary>
    /// Sample of how to display a child Eto dialog
    /// </summary>
    protected void OnChildButton()
    {
      var dialog = new SampleCsEtoHelloWorld();
      dialog.ShowModal(this);
    }

    #region IPanel methods
    public void PanelShown(uint documentSerialNumber, ShowPanelReason reason)
    {
      // Called when the panel tab is made visible, in Mac Rhino this will happen
      // for a document panel when a new document becomes active, the previous
      // documents panel will get hidden and the new current panel will get shown.
      Rhino.RhinoApp.WriteLine($"Panel shown for document {documentSerialNumber}, this serial number {m_document_sn} should be the same");
    }

    public void PanelHidden(uint documentSerialNumber, ShowPanelReason reason)
    {
      // Called when the panel tab is hidden, in Mac Rhino this will happen
      // for a document panel when a new document becomes active, the previous
      // documents panel will get hidden and the new current panel will get shown.
      Rhino.RhinoApp.WriteLine($"Panel hidden for document {documentSerialNumber}, this serial number {m_document_sn} should be the same");
    }

    public void PanelClosing(uint documentSerialNumber, bool onCloseDocument)
    {
      // Called when the document or panel container is closed/destroyed
      Rhino.RhinoApp.WriteLine($"Panel closing for document {documentSerialNumber}, this serial number {m_document_sn} should be the same");
    }
    #endregion IPanel methods
  }
}

It looks like that when GridView is in “scrollable” and in “group” it crashes when I try to redefine its DataStore.

Could someone advice how to make it not crash on mac? I have problem to debug this on mac. Rhino 7 SR14

Ɓukasz

@maxsoder or @curtisw , probably something for you to help with?

The borderSize is null. This causes crash. I will let @curtisw take a look at this as he has the best knowledge of Eto.

BR, Max

2 Likes

Hey @mlukasz87,

Thanks for reporting the issue. It looks like it’s a bug in Eto, and I’ve reported it as RH-67214.

In the meantime, you may have to refrain from putting a GridView inside a GroupBox. Also note that all panels are already in a scrollable, so you don’t need to define one yourself.

Hope this helps!

Hey @curtisw, good to know this is being worked on.

regarding scrollable, I am doing something wrong, or this also is not working as should:

no scrollable:

with scrollable:

However I have no problem with that.

Ah, I think I’m thinking of the property pages. You are correct in needing a Scrollable for a simple panel.

Curtis has fixed this in Rhino v.7.16. I have tested the sample and it does not crash anymore.

1 Like

Thank you!

1 Like

RH-67214 is fixed in Rhino 7 Service Release 16