dangerling object pointers
Posted on 1998-04-28
I would like to know how I can detect dangerling object-pointers.
Button1 := TButton.Create;
Button2 := Button1;
<< if I here try to get to any of Button2's attributes I of cause get af AccesError>>
I would like to be able to check i an object-reference points to a freed object. I cant use Assigned, cause Assigned only checks to see if the pointer is nil. My question is how do I detect if a object-reference points to somewhere that is no longer a object (It has been freed) - In the ex. above I would like to be able to do something like "Valid(Button2)" and get false, cause the object Button2 points to no longer exists.