Changeset 138 for trunk/orca

Show
Ignore:
Timestamp:
05/04/06 21:52:56 (3 years ago)
Author:
krobillard
Message:

Orca - orEnv now cleared in orFreeEnv().
Orca-Qt - User defined WIDPool objects can now be flagged for auto deletion.

Location:
trunk/orca
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ovalue.c

    r137 r138  
    523523void orFreeEnv( OEnv* env ) 
    524524{ 
     525    if( orEnv == env ) 
     526        orEnv = 0; 
     527 
    525528    orFreeArrayOfArray( &env->blocks ); 
    526529    orFreeArrayOfArray( &env->strings ); 
  • trunk/orca/qt/qorca.cpp

    r91 r138  
    3232 
    3333 
     34inline bool qEnvExists() { return qEnv.atom_close > 0; } 
     35 
     36 
    3437struct LayoutInfo 
    3538{ 
     
    103106 
    104107 
    105 int WIDPool::add( QObject* ptr, int type ) 
     108/** 
     109  Returns REC id. 
     110*/ 
     111int WIDPool::add( QObject* ptr, int type, int flags ) 
    106112{ 
    107113    int index; 
     
    114120 
    115121        rec.type   = type; 
     122        rec.flags  = flags; 
    116123        rec.object = ptr; 
    117124 
     
    123130        REC rec; 
    124131        rec.type   = type; 
     132        rec.flags  = flags; 
    125133        rec.object = ptr; 
    126134        _records.push_back( rec );  
     
    132140void WIDPool::remove( int id ) 
    133141{ 
    134     REC& rec = _records[ id ]; 
    135  
    136     assert( rec.widget );  
    137  
    138     rec.type = _freeIndex; 
    139     _freeIndex = id; 
    140     rec.object = 0; 
    141  
    142     ++_freeCount; 
     142    if( qEnvExists() ) 
     143    { 
     144        REC& rec = _records[ id ]; 
     145 
     146        assert( rec.widget );  
     147 
     148        rec.type = _freeIndex; 
     149        _freeIndex = id; 
     150        rec.object = 0; 
     151 
     152        ++_freeCount; 
     153    } 
    143154} 
    144155 
     
    13101321    // orEnv goes away. 
    13111322 
     1323    qEnv.atom_close = 0;    // Using atom_close as qEnvExists indicator. 
     1324 
    13121325    WIDPool::iterator it; 
    13131326    for( it = qEnv.pool.begin(); it != qEnv.pool.end(); ++it ) 
    13141327    { 
    1315         if( (*it).widget ) 
    1316         { 
    1317             if( (*it).type == WT_Dialog ) 
    1318             { 
    1319                 delete (*it).widget; 
    1320             } 
    1321             else if( (*it).type == WT_Widget ) 
    1322             { 
    1323                 delete (*it).widget; 
    1324             } 
    1325  
    1326             // Assuming all other widgets are deleted from WT_Dialog & 
    1327             // WT_Widget. 
     1328        // Records without DeleteObject flag set are assumed to be child 
     1329        // widgets of a WT_Dialog or WT_Widget. 
     1330 
     1331        WIDPool::REC& rec = *it; 
     1332        if( rec.object && (rec.flags & WIDPool::DeleteObject) ) 
     1333        { 
     1334            delete rec.object; 
    13281335        } 
    13291336    } 
     
    13831390SWidget::SWidget() 
    13841391{ 
    1385     _wid = qEnv.pool.add( this, WT_Widget ); 
     1392    _wid = qEnv.pool.add( this, WT_Widget, WIDPool::DeleteObject ); 
    13861393} 
    13871394 
     
    15031510 
    15041511 
    1505 #if 0 
    1506 SDialog::SDialog()  { _wid = qEnv.pool.add( this, WT_Dialog ); } 
    1507 SDialog::~SDialog() { qEnv.pool.remove( _wid ); printf("~SDialog\n"); } 
    1508 #else 
    1509 WIDGET_CODE(SDialog,WT_Dialog) 
    1510 #endif 
     1512SDialog::SDialog() 
     1513{ 
     1514    _wid = qEnv.pool.add( this, WT_Dialog, WIDPool::DeleteObject ); 
     1515} 
     1516 
     1517 
     1518SDialog::~SDialog() 
     1519{ 
     1520    qEnv.pool.remove( _wid ); 
     1521    //printf("~SDialog\n"); 
     1522} 
    15111523 
    15121524 
  • trunk/orca/qt/qorca.h

    r90 r138  
    5858public: 
    5959 
     60    enum eRecFlags 
     61    { 
     62        DeleteObject = 0x0001 
     63    }; 
     64 
    6065    struct REC 
    6166    { 
    62         int type; 
     67        short type; 
     68        short flags; 
    6369        union 
    6470        { 
     
    7076    WIDPool() : _freeCount(0), _freeIndex(-1) {} 
    7177 
    72     int  add( QObject*, int type ); 
     78    int  add( QObject*, int type, int flags = 0 ); 
    7379    void remove( int id ); 
    7480    REC* record( int id );