Recent

Author Topic: (SOLVED) Merge cells example bug?!  (Read 10174 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
(SOLVED) Merge cells example bug?!
« on: July 02, 2018, 02:51:32 pm »
Hi guys, I wanted to report a non-working example released with lazarus. This is the example to merge cells in TStringGrid. I have also attached the example, but if you compile and run mac (carbon) and double-click on a blank cell, it generates an exception in the DoEditorShow procedure. Does anyone know how to solve?
« Last Edit: July 02, 2018, 04:55:13 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 12476
Re: Merge cells example bug?!
« Reply #1 on: July 02, 2018, 03:22:48 pm »
I am the author of this example, but don't have access to Mac/carbon, and thus cannot reproduce on Win.

Double-click behavior of the standard grid was not modified in this example. Does the bug also occur with a standard string grid? There is a comment in TCustomGrid.DoEditorShow regarding carbon, but it has been there since at least version 1.6.4.

What exactly is the error message? Can you provide a stack trace?

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Merge cells example bug?!
« Reply #2 on: July 02, 2018, 03:44:41 pm »
See if the images are clear enough.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Merge cells example bug?!
« Reply #3 on: July 02, 2018, 03:44:58 pm »
Other
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 12476
Re: Merge cells example bug?!
« Reply #4 on: July 02, 2018, 03:52:02 pm »
Probably there is no editor. Modify TmcGrid.DoEditorShow like this and try again:

Code: Pascal  [Select][+][-]
  1. procedure TMCStringGrid.DoEditorShow;
  2. var
  3.   R: TRect;
  4. begin
  5.   inherited;
  6.   if goColSpanning in Options then begin
  7.     CalcCellExtent(Col, Row, R);
  8.     if Assigned(Editor) then   // <--- NEW
  9.       Editor.SetBounds(R.Left, R.Top, R.Right-R.Left-1, R.Bottom-R.Top-1);
  10.   end;
  11. end;

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Merge cells example bug?!
« Reply #5 on: July 02, 2018, 03:59:55 pm »
He did not solve. But I do not understand a thing, if you look at the image 3 you will see that the right and the bottom of R are really great. Does not it seem strange?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 12476
Re: Merge cells example bug?!
« Reply #6 on: July 02, 2018, 04:48:03 pm »
Ah, uninitialized variable! Try this
Code: Pascal  [Select][+][-]
  1. procedure TMCStringGrid.DoEditorShow;
  2. var
  3.   R: TRect;
  4. begin
  5.   inherited;
  6.   if (goColSpanning in Options) and Assigned(Editor) then begin
  7.     R := CellRect(Col, Row);
  8.     CalcCellExtent(Col, Row, R);
  9.     Editor.SetBounds(R.Left, R.Top, R.Right-R.Left-1, R.Bottom-R.Top-1);
  10.   end;
  11. end;
  12.  

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Merge cells example bug?!
« Reply #7 on: July 02, 2018, 04:55:03 pm »
Perfect. Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 12476
Re: (SOLVED) Merge cells example bug?!
« Reply #8 on: July 02, 2018, 05:51:18 pm »
Applied to trunk. Thanks for reporting.

 

TinyPortal © 2005-2018