Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


Deleting an object Find similar branches

Серж   (2001-12-18 19:18) [0]

Delete object (do Free)
How to check that the object is deleted (I check for nil - says
that the pointer is defined). How to be ???

Anatoly Podgoretsky   (2001-12-18 19:29) [1]

Well, assign it to nil after deletion.
But why do so, on the face of reuse, it is better to write so that there is no need for it.

nil   (2001-12-18 19:36) [2]

FreeAndNil (Object);

Серж   (2001-12-18 19:41) [3]

Well, it's not really "reuse."
The problem is as follows:
I do a report designer. The user can add to the report different elements (bands, labs, etc.). What lies on the report is written in tlist
Of course, you can remove and add components.
The problem came when the gang was removed. I make it free - it is deleted and deletes its child objects.
I need to remove them from lista. Therefore, the question arose. When I wanted to delete a gang, I wanted to check which objects were deleted with it and remove them from this list.
And in other cases, I assigned nil.
Should there be any way ???

Юрий Зотов   (2001-12-18 19:43) [4]

And why even check? If Free was called and there were no exceptions, then the object is deleted and no checks are needed anymore.

It seems that Anatoly Podgoretsky is right - the code logic is not built in the best way. I advise you to pay attention to this, because very often such things cause hidden and hard-to-find errors.

Серж   (2001-12-18 19:48) [5]

Okay!! Thank you all!
Even if Yu.Zotov does not know the way, then I will try to solve the problem with another and, it seems, a longer way: ((
Thanks again for your attention.

Юрий Зотов   (2001-12-18 19:52) [6]

Wow, the difference in 2 seconds ...

Now the task is clear. One way to do this. Breed your manager from TComponent, and paste your TList into it, like a field. The difference is that when inserting any component into a report, this TComponent can call its FreeNotification method and therefore will automatically receive all notifications about deletion. It remains only to replace its method Notification, and in it already clear the links in the TList.

Серж   (2001-12-18 19:57) [7]

> Yuri Zotov
Cleverly! Okay, I'll try tomorrow! Thank!

Anatoly Podgoretsky   (2001-12-18 20:25) [8]

In principle, it doesn’t matter how to do it, it’s important that any object be added and removed. himself from the list. In this case, the problem will go to the root.

Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


Memory: 0.57 MB
Time: 0.048 c
2001-11-04 11:37
Geography by IP

2001-12-19 20:41

2001-12-06 11:47
How to select data from Query using a query

2001-11-05 18:52
Competition! Wallpaper for the game (site) Sea Fight!

2001-11-03 00:47
Beta Testing !!!

afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
English French German Italian Portuguese Russian Spanish