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

Down

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];

Top









Memory: 0.58 MB
Time: 0.038 c
1-22069
Xtorm
2001-12-19 10:40
2002.01.08
How?


1-22238
T2
2001-12-16 07:29
2002.01.08
Determine the menu item number


1-22038
Dima ~
2001-12-18 17:53
2002.01.08
How to transfer command line to the launched file?


4-22502
Alexander
2001-11-06 11:00
2002.01.08
How to get an icon for a registered extension in the system


1-22218
MARcoDEN
2001-12-15 17:13
2002.01.08
Question about the DeleteFile function





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 Español 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
zulu
English French German Italian Portuguese Russian Spanish