Changeset 257 for trunk/src/root.cc


Ignore:
Timestamp:
06/14/14 22:40:25 (11 years ago)
Author:
epyon
Message:
  • object can now only created from root
  • all registration is done root side
  • gui::element draw and update logic fully in environment
  • root removed from object - a lot less coupling
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/root.cc

    r256 r257  
    1818}
    1919
    20 void nv::root::object_destroyed( object* o )
     20void nv::root::destroy_object( object* o )
    2121{
     22        destroy_children( o );
     23        o->detach();
    2224        if ( m_lua_state && o->m_lua_index != lua::ref_none )
    2325        {
     
    2830                m_uid_store->remove( o->m_uid );
    2931        }
     32        if ( o != this) delete o;
    3033}
     34
     35void nv::root::destroy_children( object* o )
     36{
     37        while ( !o->m_children.empty() )
     38        {
     39                destroy_object( o->m_children.front() );
     40        }
     41}
     42
     43void nv::root::register_with_lua( object* o, const char* lua_name, const char* storage )
     44{
     45        if ( m_lua_state )
     46        {
     47                if ( lua_name != nullptr )
     48                {
     49                        o->m_lua_index       = m_lua_state->register_object( o, lua_name );
     50                }
     51                if ( storage != nullptr )
     52                {
     53                        o->m_lua_proto_index = m_lua_state->register_proto( o, storage );
     54                }
     55        }
     56
     57}
     58
Note: See TracChangeset for help on using the changeset viewer.