Bug fixes in SlicingTree, bad refcount incrementation of BoxSet.
* Bug: In Bora::BoxSet::destroy(), perform the actual destroy only when the reference count reaches zero. In Bora::HVBoxSet CTOR, when duplicating the vector<BoxSet*> arguments, we must increase the refcount of the all the BoxSet. The refcounting mecanism of the BoxSet & NodeSet is badly implemented and should need a full reviewing and redesigning.
This commit is contained in:
parent
5f53487036
commit
5ee4487d95
|
@ -94,7 +94,10 @@ namespace Bora {
|
|||
|
||||
|
||||
void BoxSet::destroy()
|
||||
{ delete this; }
|
||||
{
|
||||
if (_cpt < 2) delete this;
|
||||
else --_cpt;
|
||||
}
|
||||
|
||||
|
||||
void BoxSet::setWidth ( DbU::Unit )
|
||||
|
@ -105,6 +108,21 @@ namespace Bora {
|
|||
{ cerr << Warning( "BoxSet::setWidth(): Must never be called." ) << endl; }
|
||||
|
||||
|
||||
string BoxSet::_getTypeName () const
|
||||
{ return "BoxSet"; }
|
||||
|
||||
|
||||
string BoxSet::_getString () const
|
||||
{
|
||||
string s = "<" + _getTypeName()
|
||||
+ " refs:" + getString(_cpt)
|
||||
+ " w:" + DbU::getValueString(getWidth ())
|
||||
+ " h:" + DbU::getValueString(getHeight())
|
||||
+ ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::HVBoxSet".
|
||||
|
||||
|
@ -112,13 +130,17 @@ namespace Bora {
|
|||
HVBoxSet::HVBoxSet ( const vector<BoxSet*>& dimensionSet, DbU::Unit height, DbU::Unit width )
|
||||
: BoxSet(height,width)
|
||||
,_dimensionSet(dimensionSet)
|
||||
{ }
|
||||
{
|
||||
for ( BoxSet* bs : _dimensionSet ) bs->incrementCpt();
|
||||
}
|
||||
|
||||
|
||||
HVBoxSet::HVBoxSet ( HVBoxSet* boxSet )
|
||||
: BoxSet( boxSet )
|
||||
, _dimensionSet( boxSet->getSet() )
|
||||
{ }
|
||||
{
|
||||
for ( BoxSet* bs : _dimensionSet ) bs->incrementCpt();
|
||||
}
|
||||
|
||||
|
||||
HVBoxSet::~HVBoxSet ()
|
||||
|
@ -133,6 +155,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string HVBoxSet::_getTypeName () const
|
||||
{ return "HVBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::HBoxSet".
|
||||
|
||||
|
@ -199,6 +225,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string HBoxSet::_getTypeName () const
|
||||
{ return "HBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::VBoxSet".
|
||||
|
||||
|
@ -266,6 +296,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string VBoxSet::_getTypeName () const
|
||||
{ return "VBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::DBoxSet".
|
||||
|
||||
|
@ -338,6 +372,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string DBoxSet::_getTypeName () const
|
||||
{ return "DBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::RHVBoxSet".
|
||||
|
||||
|
@ -379,6 +417,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string RHVBoxSet::_getTypeName () const
|
||||
{ return "RHVBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::RHBoxSet".
|
||||
|
||||
|
@ -412,6 +454,10 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string RHBoxSet::_getTypeName () const
|
||||
{ return "RHBoxSet"; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Class : "Bora::RVBoxSet".
|
||||
|
||||
|
@ -445,4 +491,8 @@ namespace Bora {
|
|||
}
|
||||
|
||||
|
||||
string RVBoxSet::_getTypeName () const
|
||||
{ return "RVBoxSet"; }
|
||||
|
||||
|
||||
} // Bora namespace.
|
||||
|
|
|
@ -699,7 +699,7 @@ namespace Bora {
|
|||
} else {
|
||||
vector<BoxSet*>::const_iterator ibs = boxSet->getSet().begin();
|
||||
for ( VSlicingNodes::iterator ichild = _children.begin()
|
||||
; ichild != _children.end(); ichild++){
|
||||
; ichild != _children.end(); ichild++) {
|
||||
(*ichild)->_setGlobalSize( *ibs );
|
||||
ibs++;
|
||||
}
|
||||
|
|
|
@ -334,6 +334,7 @@ namespace Bora {
|
|||
if (find(boxSet) == NULL) _boxSets.push_back( boxSet );
|
||||
else {
|
||||
find( boxSet )->incrementCpt();
|
||||
cerr << "NodeSets::push_back(): do not add current BoxSet, already exists." << endl;
|
||||
boxSet->destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ namespace Bora {
|
|||
virtual double getDevicesArea () const = 0;
|
||||
virtual void setHeight ( DbU::Unit );
|
||||
virtual void setWidth ( DbU::Unit );
|
||||
virtual std::string _getTypeName () const;
|
||||
virtual std::string _getString () const;
|
||||
protected:
|
||||
DbU::Unit _height;
|
||||
DbU::Unit _width;
|
||||
|
@ -106,7 +108,7 @@ namespace Bora {
|
|||
double getDevicesArea () const;
|
||||
virtual inline void calculateHeight () = 0;
|
||||
virtual inline void calculateWidth () = 0;
|
||||
|
||||
virtual std::string _getTypeName () const;
|
||||
protected:
|
||||
std::vector<BoxSet*> _dimensionSet;
|
||||
};
|
||||
|
@ -136,6 +138,7 @@ namespace Bora {
|
|||
static inline void printCount ();
|
||||
static inline void printCountAll ();
|
||||
void destroy ();
|
||||
virtual std::string _getTypeName () const;
|
||||
private:
|
||||
static int _count;
|
||||
static int _countAll;
|
||||
|
@ -168,6 +171,7 @@ namespace Bora {
|
|||
static inline void printCount ();
|
||||
static inline void printCountAll ();
|
||||
void destroy ();
|
||||
virtual std::string _getTypeName () const;
|
||||
private:
|
||||
static int _count;
|
||||
static int _countAll;
|
||||
|
@ -201,6 +205,7 @@ namespace Bora {
|
|||
static inline void printCount ();
|
||||
static inline void printCountAll ();
|
||||
void destroy ();
|
||||
virtual std::string _getTypeName () const;
|
||||
private:
|
||||
size_t _index;
|
||||
static int _count;
|
||||
|
@ -238,6 +243,7 @@ namespace Bora {
|
|||
virtual void setHeight ( DbU::Unit height ) { _height = 0; };
|
||||
virtual void setWidth ( DbU::Unit width ) { _width = 0; };
|
||||
void print () const;
|
||||
virtual std::string _getTypeName () const;
|
||||
protected:
|
||||
static int _count;
|
||||
static int _countAll;
|
||||
|
@ -260,13 +266,14 @@ namespace Bora {
|
|||
class RHBoxSet: public RHVBoxSet
|
||||
{
|
||||
protected:
|
||||
RHBoxSet ( DbU::Unit height=0 );
|
||||
RHBoxSet ( RHBoxSet* );
|
||||
~RHBoxSet ();
|
||||
public:
|
||||
static RHBoxSet* create ( DbU::Unit height );
|
||||
RHBoxSet* clone ();
|
||||
inline void setHeight ( DbU::Unit height );
|
||||
RHBoxSet ( DbU::Unit height=0 );
|
||||
RHBoxSet ( RHBoxSet* );
|
||||
~RHBoxSet ();
|
||||
public:
|
||||
static RHBoxSet* create ( DbU::Unit height );
|
||||
RHBoxSet* clone ();
|
||||
inline void setHeight ( DbU::Unit height );
|
||||
virtual std::string _getTypeName () const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -280,13 +287,14 @@ namespace Bora {
|
|||
class RVBoxSet: public RHVBoxSet
|
||||
{
|
||||
protected:
|
||||
RVBoxSet ( DbU::Unit width=0 );
|
||||
RVBoxSet ( RVBoxSet* boxSet );
|
||||
~RVBoxSet ();
|
||||
public:
|
||||
static RVBoxSet* create ( DbU::Unit width );
|
||||
RVBoxSet* clone ();
|
||||
inline void setWidth ( DbU::Unit width );
|
||||
RVBoxSet ( DbU::Unit width=0 );
|
||||
RVBoxSet ( RVBoxSet* boxSet );
|
||||
~RVBoxSet ();
|
||||
public:
|
||||
static RVBoxSet* create ( DbU::Unit width );
|
||||
RVBoxSet* clone ();
|
||||
inline void setWidth ( DbU::Unit width );
|
||||
virtual std::string _getTypeName () const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -313,4 +321,38 @@ namespace Bora {
|
|||
|
||||
} // Bora namespace.
|
||||
|
||||
GETSTRING_POINTER_SUPPORT(Bora::BoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::HVBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::HBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::VBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::DBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::RHVBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::RHBoxSet)
|
||||
GETSTRING_POINTER_SUPPORT(Bora::RVBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::BoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::HVBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::HBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::VBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::DBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::RHVBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::RHBoxSet)
|
||||
GETSTRING_REFERENCE_SUPPORT(Bora::RVBoxSet)
|
||||
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::BoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::HVBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::HBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::VBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::DBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::RHVBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::RHBoxSet)
|
||||
IOSTREAM_POINTER_SUPPORT(Bora::RVBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::BoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::HVBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::HBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::VBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::DBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::RHVBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::RHBoxSet)
|
||||
IOSTREAM_REFERENCE_SUPPORT(Bora::RVBoxSet)
|
||||
|
||||
#endif // BORA_BOX_SET_H
|
||||
|
|
Loading…
Reference in New Issue