From 5328240c21b902a15cf70a2288efaddde3b3936b Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 20 Jun 2008 15:36:36 +0000 Subject: [PATCH] * ./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. --- hurricane/src/hviewer/CellViewer.cpp | 8 ++++---- hurricane/src/hviewer/HInspectorWidget.cpp | 15 ++++++++------- hurricane/src/hviewer/RecordModel.cpp | 5 +---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/hurricane/src/hviewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp index b3084bbc..e0a58a02 100644 --- a/hurricane/src/hviewer/CellViewer.cpp +++ b/hurricane/src/hviewer/CellViewer.cpp @@ -160,12 +160,12 @@ namespace Hurricane { void CellViewer::runInspector ( Record* record ) { - //cerr << "INITIAL Records: " << Record::getAllocateds() << endl; - //cerr << "INITIAL Slots: " << Slot::getAllocateds() << endl; - //cerr << "Inspector created." << endl; + static HInspectorWidget* inspector = NULL; if ( record ) { - HInspectorWidget* inspector = new HInspectorWidget (); + //if ( !inspector ) + inspector = new HInspectorWidget (); + inspector->setRootRecord ( record ); inspector->show (); } else diff --git a/hurricane/src/hviewer/HInspectorWidget.cpp b/hurricane/src/hviewer/HInspectorWidget.cpp index fd64b587..c4c3729f 100644 --- a/hurricane/src/hviewer/HInspectorWidget.cpp +++ b/hurricane/src/hviewer/HInspectorWidget.cpp @@ -91,17 +91,17 @@ namespace Hurricane { void HInspectorWidget::History::clear ( bool inDelete ) { if ( !_slots.empty() ) { - // Delete the rootRecord only if it'not the current viewed record. - if ( _depth != 0 ) { - delete _slots[0]->getDataRecord(); - } + _comboBox->clear (); + + // Delete the rootRecord as it's the only one not deleted + // automatically through RecordModel (case of depth 0). + delete _slots[0]->getDataRecord(); for ( size_t i=0 ; i < _slots.size() ; i++ ) delete _slots[i]; _slots.clear (); - if ( !inDelete ) - _comboBox->clear (); + _depth = 0; } } @@ -124,7 +124,6 @@ namespace Hurricane { Slot* rootSlot = ::getSlot ( "", rootRecord ); _slots.push_back ( rootSlot ); _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 ) { + if ( depth < 0 ) return; + _history.goTo ( depth ); setSlot (); } diff --git a/hurricane/src/hviewer/RecordModel.cpp b/hurricane/src/hviewer/RecordModel.cpp index ef30b366..351e5639 100644 --- a/hurricane/src/hviewer/RecordModel.cpp +++ b/hurricane/src/hviewer/RecordModel.cpp @@ -20,7 +20,7 @@ namespace Hurricane { RecordModel::~RecordModel () { - delete _record; + if ( _depth ) delete _record; delete _slot; } @@ -33,8 +33,6 @@ namespace Hurricane { return false; } - emit layoutAboutToBeChanged (); - if ( _depth ) delete _record; if ( _slot ) delete _slot; @@ -99,7 +97,6 @@ namespace Hurricane { int RecordModel::rowCount ( const QModelIndex& parent ) const { - return (_record) ? _record->_getSlotList().size() : 0; }