From ecc9c5402f410b25c1db13d591b63ecd2773397b Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 3 Feb 2009 17:58:06 +0000 Subject: [PATCH] * ./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. --- hurricane/src/hurricane/hurricane/Commons.h | 22 +++++++++++++++++++++ hurricane/src/hviewer/CellViewer.cpp | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hurricane/src/hurricane/hurricane/Commons.h b/hurricane/src/hurricane/hurricane/Commons.h index a3b79b95..423f3e4c 100644 --- a/hurricane/src/hurricane/hurricane/Commons.h +++ b/hurricane/src/hurricane/hurricane/Commons.h @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -83,6 +84,27 @@ namespace Hurricane { + // x-------------------------------------------------------------x + // | shared_ptr<> support for DBo | + // x-------------------------------------------------------------x + + + template + class DboDestroy { + public: + inline void operator() ( DboType* dbo ) { dbo->destroy(); } + }; + + + template + class dbo_ptr : public tr1::shared_ptr { + public: + dbo_ptr ( DboType* dbo ) : tr1::shared_ptr(dbo,DboDestroy()) { } + }; + + + + // x-------------------------------------------------------------x // | Miscellaneous Utilites | // x-------------------------------------------------------------x diff --git a/hurricane/src/hviewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp index 2cf15215..a01f1779 100644 --- a/hurricane/src/hviewer/CellViewer.cpp +++ b/hurricane/src/hviewer/CellViewer.cpp @@ -331,8 +331,10 @@ namespace Hurricane { void CellViewer::setCell ( Cell* cell ) { + Name cellName = (cell) ? cell->getName() : "empty"; + list< shared_ptr >::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 );