Forum > Editor

Possible bug, TTreeNode.Items.Data data disappears in DFM and LFM files

(1/2) > >>

max555:
Hello,
Looks like there are couple bugs in Lazarus 3.4 for Linux

1) menu Tool -> Delphi conversion -> Convert Delphi unit to Lazarus unit
This tool often removes Items.Data property, at least for TTreeNode.Items.Data. I tried several forms with the same result

2) Ok, I copied TTreeNode.Items.Data from original DFM file into LFM, and there is bug #2
- I modified LFM, saved file, compiled project - error, still no TTreeNode.Items.Data in the module.
- Ok, I opened and closed source files in IDE, I removed .o, .ppu, .lfm files in output directory, recompiled project - same error, still no TTreeNode.Items.Data in the module.
The only way to fix the problem - restart Lazarus IDE

3) But its not over. Everything compiled and worked and then error returned by itself - TTreeNode.Items.Data was removed from .LFM file again.
Problem #3 related to 1 LFM file so far, while problems #1 and #2 reproduced on several different forms.

Thank you

wp:
Please be more specific and exact. To my knowledge, there is no TTreeNode.Items.Data property, only a TTreeNode.Data. Is it that what you mean?

I would be surprised when Lazarus streams TTreeNode.Data at all since this is a pointer which will point to nowhere after reading. How even can you assign something to TreeNode.Data at designtime to be streamed since there is no GUI for that?

Post a small sample project demonstrating the issue.

max555:
Yes, looks like there is no such property but somehow it works and application load tree items when specified in LFM file.
Delphi stores items in this property as hex string
It looks like
  object LargeTree: TTreeView
    Left = 0
    Top = 0
    Width = 154
    Height = 285
    Items.Data = {
      1200000024000000000000000000000000000000FFFFFFFF0000000000000000
      0B507265666572656E63657321000000000000000000000001000000FFFFFFFF
      0000000000000000084265686176696F72200000000000000000000000020000
      00FFFFFFFF000000000100000007537461727475702000000000000000000000
      0000FFFFFFFF00000000000000000C436F6D70616374206C6F67732600000000
      0000000000000009000000FFFFFFFF00000000000000000D484D207379737465
      ....}
So compiled project is able to load data correctly but converter and sometimes IDE removes such data

max555:
PS
If I create original Lazarus form, it looks the same


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---object Form1: TForm1  Left = 248  Height = 462  Top = 145  Width = 611  Caption = 'Form1'  ClientHeight = 462  ClientWidth = 611  LCLVersion = '3.4.0.0'  object TreeView1: TTreeView    Left = 27    Height = 428    Top = 20    Width = 565    TabOrder = 0    Items.Data = {      F9FFFFFF020002000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF010000000000      000001050000004974656D30FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01000000      0000000001050000004974656D31FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000      00000000000000050000004974656D32FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF      010000000000000001050000004974656D33FFFFFFFFFFFFFFFFFFFFFFFFFFFF      FFFF010000000000000001050000004974656D34FFFFFFFFFFFFFFFFFFFFFFFF      FFFFFFFF000000000000000000050000004974656D35    }  endend
and so far it does not remove this property by itself

wp:
Now I understand. The node TreeView.Items.Data in the lfm file is a compact presentation of the nodes, and it seems that Delphi and Lazarus are doing it differently: Lazarus begins with a "MagicNumber" (-7 = 'F9FFFFFF'), a version identifcation, the number of top-level nodes and then the nodes themselves (TTreeNodeInfo), while Delphi only writes the number of nodes and then the nodes as TDelphiNodeInfo records (see TTreeNodes.ReadData and TTreeNode.ReadData in treeview.inc). The lfm reader of Lazarus is able to detect the originator and read Delphi files accordingly. But: The reader only seems to know the format of Delphi 7. When I create a form with Delphi XE 11, the node is no longer called Items.Data, but Items.NodeData. I don't know when the switch occured, probably when the Unicode was introduced, but the difference is fatal. Lazarus does not know the identifier "Items.NodeData" and refuses to load this part of the dfm file... Even Delphi 7 cannot read its files once they were opened by XE11.

I'll have to investigate more details - maybe there is a way to fix the new Delphi files. Or I'll write a bug-report so that somebody else can have a look at it.

Navigation

[0] Message Index

[#] Next page

Go to full version