- Timestamp:
- 06/19/14 01:57:53 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gui/gui_environment.hh
r257 r264 33 33 }; 34 34 35 class environment : public root35 class environment 36 36 { 37 37 public: … … 44 44 void update(); 45 45 void draw(); 46 virtual void add_child( object* child ); 46 void add_child( element* child ); 47 void destroy_element( element* e ); 48 void destroy_children( element* e ); 47 49 virtual ~environment(); 48 50 protected: 51 49 52 renderer* m_renderer; 50 53 window* m_window; -
trunk/nv/root.hh
r262 r264 17 17 * Implements the root of a object tree-like structure. 18 18 */ 19 class root : public object19 class root 20 20 { 21 21 public: 22 root() : object( "" ),m_lua_state( nullptr ), m_uid_store( nullptr ) {}22 root() : m_lua_state( nullptr ), m_uid_store( nullptr ) {} 23 23 lua::state* get_lua_state() const { return m_lua_state; } 24 24 uid_store* get_uid_store() const { return m_uid_store; } … … 33 33 void destroy_children( object* o ); 34 34 virtual void destroy_object( object* o ); 35 virtual ~root() { destroy_object( this );}35 virtual ~root() {} 36 36 protected: 37 37 virtual void object_created( object* o ); … … 40 40 uid_store* m_uid_store; 41 41 }; 42 42 43 43 } // namespace nv 44 44 -
trunk/src/gui/gui_environment.cc
r257 r264 36 36 m_screen = new screen( m_area ); 37 37 m_renderer = new renderer( w, shader_path ); 38 root::add_child( m_screen );39 38 } 40 39 … … 47 46 { 48 47 element* result = new element( r ); 49 object_created( result );50 48 if ( parent == nullptr ) parent = m_screen; 51 49 parent->add_child( result ); 52 50 return result; 51 } 52 53 void nv::gui::environment::destroy_element( element* e ) 54 { 55 destroy_children( e ); 56 e->detach(); 57 delete e; 53 58 } 54 59 … … 94 99 } 95 100 96 void environment::add_child( object* child )101 void environment::add_child( element* child ) 97 102 { 98 // TODO: check if element99 103 m_screen->add_child( child ); 100 104 } 101 105 106 void environment::destroy_children( element* e ) 107 { 108 while ( !e->m_children.empty() ) 109 { 110 destroy_element( (element*)e->m_children.front() ); 111 } 112 } 113 114 102 115 environment::~environment() 103 116 { 104 destroy_ children( this);117 destroy_element( m_screen ); 105 118 delete m_renderer; 106 119 } -
trunk/src/root.cc
r262 r264 30 30 m_uid_store->remove( o->m_uid ); 31 31 } 32 if ( o != this)delete o;32 delete o; 33 33 } 34 34
Note: See TracChangeset
for help on using the changeset viewer.