Access violation in fmx270.bpl with TMSFNCGrid

This should reproduce the error:

  1. Add a TMSFMXGrid to the form (I'm in the process of migrating to FNC)
  2. Add a TMSFNCGrid to a form
  3. set it to only two columns
  4. make those two columns ctCheckBox
  5. 0 Fixed Columns
  6. assign some code to an event (OnCellCheckBoxClick will do but also with other events)
  7. save

Then when I switch backwards and forwards between code/design at some point when switching to design I get a series Delphi error

Access violation at address 0AC03AEF in module 'fmx270.bpl'.
Read of address 00000010.

I have to delete the FNC component to get things working again.

Hi,

We are able to reproduce this and are currently looking into the issue. Thanks for reporting!

Hi,

We have applied a fix, the next version will address this.

Thanks Pieter. Is there anything I can do now before the new version? I can workaround it if not.

Hi,

Unfortunately we cannot release an update right away, as we are currently testing a new version and adding new content. The next version is planned for next week.

the fix is in FMX.TMSFNCCustomGrid.pas and involves moving a couple of lines of code:

Incorrect code:

          cell := FCellArray[ci, ri];
          if Assigned(cell) and IsBaseCell(c, r) then
          begin
            rctl := RectF(cell.Left, cell.Top, cell.Left + cell.Width, cell.Top + cell.Height);
            rt := cell.GetTextRect;
            {$IFDEF LCLLIB}
            InflateRectEx(rt, -4, -2);
            {$ENDIF}
            {$IFNDEF LCLLIB}
            InflateRectEx(rt, -2, -2);
            {$ENDIF}
            if cell is TTMSFNCCheckGridCell then
              (cell as TTMSFNCCheckGridCell).ControlBitmap := GetCheckBoxBitmap((cell as TTMSFNCCheckGridCell).Checked, False);

            if cell is TTMSFNCRadioGridCell then
              (cell as TTMSFNCRadioGridCell).ControlBitmap := GetRadioButtonBitmap((cell as TTMSFNCRadioGridCell).Checked, False);

            if cell is TTMSFNCNodeGridCell then
              (cell as TTMSFNCNodeGridCell).ControlBitmap := GetNodeBitmap((cell as TTMSFNCNodeGridCell).State);

            if cell is TTMSFNCButtonGridCell then
              (cell as TTMSFNCButtonGridCell).ControlBitmap := GetDummyButtonBitmap(cell as TTMSFNCButtonGridCell);

            if not dr then
              cell.Layout.Stroke.Assign(Appearance.NormalLayout.Stroke);

            cell.Draw(AGraphics, dr, dr, True);

Corrected code:

          cell := FCellArray[ci, ri];
          if Assigned(cell) and IsBaseCell(c, r) then
          begin
            rctl := RectF(cell.Left, cell.Top, cell.Left + cell.Width, cell.Top + cell.Height);

            if cell is TTMSFNCCheckGridCell then
              (cell as TTMSFNCCheckGridCell).ControlBitmap := GetCheckBoxBitmap((cell as TTMSFNCCheckGridCell).Checked, False);

            if cell is TTMSFNCRadioGridCell then
              (cell as TTMSFNCRadioGridCell).ControlBitmap := GetRadioButtonBitmap((cell as TTMSFNCRadioGridCell).Checked, False);

            if cell is TTMSFNCNodeGridCell then
              (cell as TTMSFNCNodeGridCell).ControlBitmap := GetNodeBitmap((cell as TTMSFNCNodeGridCell).State);

            if cell is TTMSFNCButtonGridCell then
              (cell as TTMSFNCButtonGridCell).ControlBitmap := GetDummyButtonBitmap(cell as TTMSFNCButtonGridCell);

            if not dr then
              cell.Layout.Stroke.Assign(Appearance.NormalLayout.Stroke);

            rt := cell.GetTextRect;
            {$IFDEF LCLLIB}
            InflateRectEx(rt, -4, -2);
            {$ENDIF}
            {$IFNDEF LCLLIB}
            InflateRectEx(rt, -2, -2);
            {$ENDIF}

            cell.Draw(AGraphics, dr, dr, True);