wxXmlNode и delete

Это русская секция форума wxWidjets. В этой секции вы можете обсуждать любые вопросы, связанные с wxWidgets на вашем родном языке.
Post Reply
vat_cpp
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Nov 15, 2019 4:31 pm

wxXmlNode и delete

Post by vat_cpp » Wed Apr 29, 2020 12:50 pm

Рассматривается однопоточное приложение / this case is about single-thread app

В описании класса есть замечание:
Once a wxXmlNode has been added to a wxXmlDocument it becomes owned by the document and this has two implications. Firstly, the wxXmlDocument takes responsibility for deleting the node so the user should not delete it; and secondly, a wxXmlNode must always be created on the heap and never on the stack.

То есть, где бы мы ни создали (не важно, в какой функции и т.д.) объект wxXmlNode* = new wxXmlNode(... , если указатель на него в итоге попадает как child в root-node какого-либо wxXmlDocument, этот Document при срабатывании его деструктора сам этот указатель на node и должен освободить?

//

So, no matter where node object was created (in which function), since its pointer was captured by wxXmlDocument obj as child node of its root node, Doc object will free this node pointer when doc's destructor will be called?

Kvaz1r
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Tue Jun 07, 2016 1:07 pm

Re: wxXmlNode и delete

Post by Kvaz1r » Wed Apr 29, 2020 3:57 pm

Да

Post Reply