Recent

Author Topic: Need help understanding how streaming grid from DFM causes error  (Read 396 times)

MISV

  • Hero Member
  • *****
  • Posts: 618
I have this (granted, descendant) grid which contains the following in DFM file

Code: Pascal  [Select]
  1. ColCount = 11
  2. ColWidths = (
  3.                     129
  4.                     129
  5.                     129
  6.                     129
  7.                     129
  8.                     129
  9.                     129
  10.                     129
  11.                     129
  12.                     129
  13.                     129)
  14.  

Here is snipped from LCL grids code reading this information:

Code: Pascal  [Select]
  1. procedure TCustomGrid.ReadColWidths(Reader: TReader);
  2. var
  3.   i: integer;
  4. begin
  5.   with Reader do begin
  6.     ReadListBegin;
  7.     for i:=0 to ColCount-1 do
  8.       ColWidths[I] := ReadInteger;
  9.     ReadListEnd;
  10.   end;
  11. end;      

I have looked at the values read + colcount (11) and it all seems correct... so far so good...

But when ReadListEnd is called I get errors
Quote
EReadError with "Invalid value for property"
Quote
EReadError with "Error reading sgData.ColWidths: Invalid value for property"


Any idea on what this error could be caused by?

1) Yes this is a grid descendant
2) Yes the file is DFM because I also use it in Delphi project

But concerning #1 #2 I have taken great care to keep everything compatible and the DFM file looks fully correct in Lazarus as well... (tried load/save the form in Lazarus first) But I am open to any suggestion on in which direction I should look.

jamie

  • Hero Member
  • *****
  • Posts: 1893
Re: Need help understanding how streaming grid from DFM causes error
« Reply #1 on: August 16, 2019, 08:31:33 pm »
you need to convert it to Lazarus, it should be a LFM file.

Use the file converter utils in the tools menu..

Thaddy

  • Hero Member
  • *****
  • Posts: 8671
Re: Need help understanding how streaming grid from DFM causes error
« Reply #2 on: August 16, 2019, 08:42:48 pm »
you need to convert it to Lazarus, it should be a LFM file.

Use the file converter utils in the tools menu..
DFM is also - somewhat - supported, but probably depends on Delphi version. e.g. a D7 dfm is OK

As per the same converter option!
Most people that want to use threading should learn to patch their jeans first: use a needle.

MISV

  • Hero Member
  • *****
  • Posts: 618
Re: Need help understanding how streaming grid from DFM causes error
« Reply #3 on: August 16, 2019, 09:54:36 pm »
you need to convert it to Lazarus, it should be a LFM file.

Use the file converter utils in the tools menu..

I have over half million lines of code working using a lot of *huge* DFM forms using a huge variety of controls giving me full cross tool and cross platform choices for many yeas now.

First time I have encountered a problem not easily solvable. Not really a preferred option to maintain two different set of form files.

Actually I also usually do not have problems with my grid solution that "bridges" VCL/Lazarus differences... But the weird thing is I have not touched anything in the form. All in all very puzzling :-/

« Last Edit: August 16, 2019, 10:01:45 pm by MISV »

MISV

  • Hero Member
  • *****
  • Posts: 618
Re: Need help understanding how streaming grid from DFM causes error
« Reply #4 on: August 16, 2019, 10:00:24 pm »
you need to convert it to Lazarus, it should be a LFM file.

Use the file converter utils in the tools menu..
DFM is also - somewhat - supported, but probably depends on Delphi version. e.g. a D7 dfm is OK

As per the same converter option!

Yes there are things that can break Lazarus loading DFM files. But then you usually get errors like some property is not recognized or similar. Generally speaking it works very well as long as you are a bit careful. (What I can't set in DFM that is compatible I set runtime.) In myopinion it almos should be promoted more that Lazarus/LCL is more compatible with Delphi/VCL than Delphi/Firemonkey. It is the quickest to x-platform in many ways.

However - this issue is a bit strange because the DFM/LFM stuff is the same, correct properties, values etc. as far as I can tell. Maybe the Lazarus/DFM-text gets converted to something incorrect in Lazarus/DFM-binary. In this case the error received is not about an unknown property ... and it even loads the content correctly... But it is the ReadListEnd; call that fails. i have not tried that before.

jamie

  • Hero Member
  • *****
  • Posts: 1893
Re: Need help understanding how streaming grid from DFM causes error
« Reply #5 on: August 16, 2019, 10:23:36 pm »
Just by coincidence is this the last item in the DFM file to be read?

Also, I wonder if there are some white spaces or TABS in the file.

MISV

  • Hero Member
  • *****
  • Posts: 618
Re: Need help understanding how streaming grid from DFM causes error
« Reply #6 on: August 17, 2019, 12:50:14 am »
No tabs and not end of file / last component in dfm/fm.

I am also considering simply removing all columns design time and set them runtime. That would kinda also solve this issue and might be faster than trying to debug it... I will give it one last try getting my head wrapped around it
« Last Edit: August 17, 2019, 01:38:15 am by MISV »

jamie

  • Hero Member
  • *****
  • Posts: 1893
Re: Need help understanding how streaming grid from DFM causes error
« Reply #7 on: August 17, 2019, 02:04:42 am »
I am carious if you are having some sort of resource problem ?

 I assume you have debug info turned on, could you configure it to use an external symbol  file instead of it being attached to the EXE ? I have had issues like that before with large projects where the LFM/DFM is large and the debug info is attached also.

  I normally use external symbol file anyways for all my projects.



MISV

  • Hero Member
  • *****
  • Posts: 618
Re: Need help understanding how streaming grid from DFM causes error
« Reply #8 on: August 17, 2019, 03:26:00 am »
I am carious if you are having some sort of resource problem ?

 I assume you have debug info turned on, could you configure it to use an external symbol  file instead of it being attached to the EXE ? I have had issues like that before with large projects where the LFM/DFM is large and the debug info is attached also.

  I normally use external symbol file anyways for all my projects.

It freaking works now after changing debug to external (I also did a full rebuild) Thank you

I am on Mac/LCLCocoa if that matters. (So debugger not always working that well / debugger crashes pretty easily - at least for me)

Funny fact - the IDE in Lazarus can load the form/grid fine... Which I guess makes sense seeing what the solution was

Should this maybe be reported as a bug somewhere? Maybe the generated error message could mention this as an option? Or something! :)

jamie

  • Hero Member
  • *****
  • Posts: 1893
Re: Need help understanding how streaming grid from DFM causes error
« Reply #9 on: August 17, 2019, 08:08:09 pm »
I am glad you have it operating, I don't know much about the OS you are on, it could have some limitations that are effecting your tools.

 Maybe it would be a good idea to report this in the bug room..


 Personally I would elect to use a external symbol file by default.