Well, without testing, I would say: Move the TLabelPanel "inherited create" call to the end of the constructor.I just checked, that doesn't work either, when setting the Parent of the child (i.e. self), then the application crashes, because the component isn't properly initialized.
I just checked, that doesn't work either, when setting the Parent of the child (i.e. self), then the application crashes, because the component isn't properly initialized.
Seems like csLoading is not set.It is only set, if someone sets it.
Also for some reason TReader is not always setting it (or not always at the same time). Depends on inlining, which IIRC is e.g. used by frames....
But I do not recall all details....
How old a compiler version? And does not the rest of the IDE need an up todate compiler too (unless you use an old IDE)?
If the owner (i.e Tchild.Create(self)) works, then you can move the ".Parent" assignment after the initialized.I just tried that, it works. Yes, as you said, its not ideal for compact code. Also the 'self' thing I don't like. For such things I always fear that something gets broken in deeper levels without a direct crash. Thats also why I opened this topic. But seems at least one can relay on the crash because the children are automatically initialized with nil.
Of course that breaks the code into small bits...
QuoteSeems like csLoading is not set.It is only set, if someone sets it.
TReader does set it.
You can call Self.Loading to set it.
And then Self.Loaded to clear it.
Also the 'self' thing I don't like. For such things I always fear that something gets broken in deeper levels without a direct crash. Thats also why I opened this topic. But seems at least one can relay on the crash because the children are automatically initialized with nil.It is perfectly legal to do
What should be possible regarding 'self', is to use the owner of the Form (TheOwner passed in Create) instead of 'self' and then deleting the Child manually in Destroy instead of relying on the Owner.
In the first case, you can destroy it if you do so before the owner gets destroyed. But if you get destroyed be the owner, then LabelPanel may have already gone.Right, I missed that.