* ./hurricane/src/hviewer :

- Bug: very tricky one. Do not emit "layoutAboutToChange()" signal
       after destroying the Record used by the RecordModel but before
       setting a new one and not setting the _record field to NULL.
       Now setRootRecord() should work more than once.
This commit is contained in:
Jean-Paul Chaput 2008-06-20 15:36:36 +00:00
parent fd0051802b
commit 5328240c21
3 changed files with 13 additions and 15 deletions

View File

@ -160,12 +160,12 @@ namespace Hurricane {
void CellViewer::runInspector ( Record* record ) void CellViewer::runInspector ( Record* record )
{ {
//cerr << "INITIAL Records: " << Record::getAllocateds() << endl; static HInspectorWidget* inspector = NULL;
//cerr << "INITIAL Slots: " << Slot::getAllocateds() << endl;
//cerr << "Inspector created." << endl;
if ( record ) { if ( record ) {
HInspectorWidget* inspector = new HInspectorWidget (); //if ( !inspector )
inspector = new HInspectorWidget ();
inspector->setRootRecord ( record ); inspector->setRootRecord ( record );
inspector->show (); inspector->show ();
} else } else

View File

@ -91,17 +91,17 @@ namespace Hurricane {
void HInspectorWidget::History::clear ( bool inDelete ) void HInspectorWidget::History::clear ( bool inDelete )
{ {
if ( !_slots.empty() ) { if ( !_slots.empty() ) {
// Delete the rootRecord only if it'not the current viewed record. _comboBox->clear ();
if ( _depth != 0 ) {
// Delete the rootRecord as it's the only one not deleted
// automatically through RecordModel (case of depth 0).
delete _slots[0]->getDataRecord(); delete _slots[0]->getDataRecord();
}
for ( size_t i=0 ; i < _slots.size() ; i++ ) for ( size_t i=0 ; i < _slots.size() ; i++ )
delete _slots[i]; delete _slots[i];
_slots.clear (); _slots.clear ();
if ( !inDelete ) _depth = 0;
_comboBox->clear ();
} }
} }
@ -124,7 +124,6 @@ namespace Hurricane {
Slot* rootSlot = ::getSlot ( "<TopLevelSlot>", rootRecord ); Slot* rootSlot = ::getSlot ( "<TopLevelSlot>", rootRecord );
_slots.push_back ( rootSlot ); _slots.push_back ( rootSlot );
_comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str())); _comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str()));
_depth = 0;
} }
@ -277,6 +276,8 @@ namespace Hurricane {
void HInspectorWidget::historyChanged ( int depth ) void HInspectorWidget::historyChanged ( int depth )
{ {
if ( depth < 0 ) return;
_history.goTo ( depth ); _history.goTo ( depth );
setSlot (); setSlot ();
} }

View File

@ -20,7 +20,7 @@ namespace Hurricane {
RecordModel::~RecordModel () RecordModel::~RecordModel ()
{ {
delete _record; if ( _depth ) delete _record;
delete _slot; delete _slot;
} }
@ -33,8 +33,6 @@ namespace Hurricane {
return false; return false;
} }
emit layoutAboutToBeChanged ();
if ( _depth ) delete _record; if ( _depth ) delete _record;
if ( _slot ) delete _slot; if ( _slot ) delete _slot;
@ -99,7 +97,6 @@ namespace Hurricane {
int RecordModel::rowCount ( const QModelIndex& parent ) const int RecordModel::rowCount ( const QModelIndex& parent ) const
{ {
return (_record) ? _record->_getSlotList().size() : 0; return (_record) ? _record->_getSlotList().size() : 0;
} }