delphi - Could omission of "^" when accessing a record pointer's members cause an access violation? -


In VirtualTreeview, I am storing my data in PVirtualNodes . I have many in my app Access violation (usually "Read the address 00000000" ), and they mostly (I really dare to say always) when I am doing something with my node data.

However, this is the thing, I used to do my stuff; Use it like this:

  // dummy code - IDE var MyNode: PVirtualNode; MyData: PMIDoddata; Start MyNode: = VST.GetFirst selected; If assigned (MyNode) then start MyData: = VST.GetNodeData (MyNode); If assigned (MyData) then start MyData.DummyProperty: = 'Test'; End; End; End;   

As you've probably seen, By MyData "dereference" (right?) Do not "MyData" Are you ^ ! The reason for this is not that I have been told that it was not necessary to add caret to the pointer, although I think there is something to do with it. If I knew, then I am not posting here. ;)

So my question is, is it necessary to add this small ^ to MyData? And is it possible that by not doing so, can I have an admission violation?

When you have a pointer to a record, you can leave ^. The following are the parallel:

  MyData.DummyProperty MyData ^. DummyProperty   

This is also a matter for the deprecated turbo pascal item . I hope to do this for Delphi classes, although I have never tried it because they are already reference types.

Unfortunately, this is not an explanation for your AV.

Comments