* ./hurricane/src/hviewer :

- Bug: in CellViewer::setCell(), do not try to get the name of the cell if
        it's a NULL pointer... Solve the cyclop "empty cell" coredump problem.
    - New feature : dbo_destroy<> a shared_ptr<> that calls the destroy method
        of an object, specially tailored for DBo. Application in Cyclop.
This commit is contained in:
Jean-Paul Chaput 2009-02-03 17:58:06 +00:00
parent 78be633226
commit ecc9c5402f
2 changed files with 25 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include <cstdio>
#include <cassert>
#include <tr1/memory>
#include <string>
#include <list>
#include <set>
@ -83,6 +84,27 @@ namespace Hurricane {
// x-------------------------------------------------------------x
// | shared_ptr<> support for DBo |
// x-------------------------------------------------------------x
template<typename DboType>
class DboDestroy {
public:
inline void operator() ( DboType* dbo ) { dbo->destroy(); }
};
template<typename DboType>
class dbo_ptr : public tr1::shared_ptr<DboType> {
public:
dbo_ptr ( DboType* dbo ) : tr1::shared_ptr<DboType>(dbo,DboDestroy<DboType>()) { }
};
// x-------------------------------------------------------------x
// | Miscellaneous Utilites |
// x-------------------------------------------------------------x

View File

@ -331,8 +331,10 @@ namespace Hurricane {
void CellViewer::setCell ( Cell* cell )
{
Name cellName = (cell) ? cell->getName() : "empty";
list< shared_ptr<CellWidget::State> >::iterator istate
= find_if ( _cellHistory.begin(), _cellHistory.end(), CellWidget::FindStateName(cell->getName()) );
= find_if ( _cellHistory.begin(), _cellHistory.end(), CellWidget::FindStateName(cellName) );
if ( istate != _cellHistory.end() ) {
emit stateChanged ( *istate );