Subject | Re: [IBO] IB_Query-Destroy Message |
---|---|
Author | Frank Ingermann |
Post date | 2001-05-04T22:53:49Z |
Hi Guido,
guido.klapperich@... wrote:
work: you should override the Notification method of your self-written compo.
something like:
(in interface)
public
procedure Notification(aComponent:TComponent; Operation:TOperation);
override;
(in implementation)
procedure TMyCompo.Notification(aComponent:TComponent; Operation:TOperation);
begin
if (aComponent = fMyDataSet) and (Operation=opRemove) then
fMyDataSet := NIL;
inherited;
end;
when the IB_Query1 gets destroyed, Delphi calls the Notification meth for all
other compos (this is the "say hello, wave goodbye" meth :-) so you can detect
in your compo that something it points to is about to be destroyed.
one of the things that make hatching objects a bit unpleasant - if you don't
provide a way to clean up dangling references, they'll just dangle into AVs ;)
regards & hope this helps,
fingerman
guido.klapperich@... wrote:
>i don't know if it sends a message, but the "pure oop" approach will surely
> Send a IB_Query any message before it get destroyed ? The background is
> this, that I have self-written component with a property Dataset:
> TIB_BDataset. When I set Dataset:=IB_Query1 for example and then delete
> IB_Query1, I get an AV, so I need to know, if the Query has been
> deleted. Any ideas ?
>
> Guido.
work: you should override the Notification method of your self-written compo.
something like:
(in interface)
public
procedure Notification(aComponent:TComponent; Operation:TOperation);
override;
(in implementation)
procedure TMyCompo.Notification(aComponent:TComponent; Operation:TOperation);
begin
if (aComponent = fMyDataSet) and (Operation=opRemove) then
fMyDataSet := NIL;
inherited;
end;
when the IB_Query1 gets destroyed, Delphi calls the Notification meth for all
other compos (this is the "say hello, wave goodbye" meth :-) so you can detect
in your compo that something it points to is about to be destroyed.
one of the things that make hatching objects a bit unpleasant - if you don't
provide a way to clean up dangling references, they'll just dangle into AVs ;)
regards & hope this helps,
fingerman