Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Proposed change to U++ to allow owning children.
Re: revised ownership change [message #32171 is a reply to message #32170] Thu, 28 April 2011 23:54 Go to previous messageGo to previous message
Lance is currently offline  Lance
Messages: 656
Registered: March 2007
Contributor
In the rare case where we are destructing its parent but could not make up our mind whether we are going to delete it or assign it to yet another parent (not decided at the moment), we can use a dirty trick to circumvent the no-reattachment limitations,

{
   // p is pointed to a dynamically created child

   ParentCtrl tmp;
   tmp.Add(p); // or should it be *p? I rely on TheIDE on this
               // now p is no longer part of its previous parent's
               // child tree.

   // Destruct its previous parent to free precious memory resource :)
   // and since *p belongs somewhere else, it will not be touched.

   // a thousand lines/function calls to make up our mind whether
   // we are going to destruct *p or add it to another parent.

   if( newdad !=NULL)
       newdad->Add(p);

   // we don't even need to detach and delete, as p will be 
   // destructed with tmp at the end of the code block
   // if a newdad is not successfully found.
   // this is the expected behavior

}

[Updated on: Thu, 28 April 2011 23:59]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Get MAC addresses for windows and linux
Next Topic: Testing framework in U++.
Goto Forum:
  


Current Time: Sat Aug 30 00:31:02 CEST 2025

Total time taken to generate the page: 0.03635 seconds