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()
|
void BoxSet::destroy()
|
||||||
{ delete this; }
|
{
|
||||||
|
if (_cpt < 2) delete this;
|
||||||
|
else --_cpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BoxSet::setWidth ( DbU::Unit )
|
void BoxSet::setWidth ( DbU::Unit )
|
||||||
|
@ -105,6 +108,21 @@ namespace Bora {
|
||||||
{ cerr << Warning( "BoxSet::setWidth(): Must never be called." ) << endl; }
|
{ 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".
|
// Class : "Bora::HVBoxSet".
|
||||||
|
|
||||||
|
@ -112,13 +130,17 @@ namespace Bora {
|
||||||
HVBoxSet::HVBoxSet ( const vector<BoxSet*>& dimensionSet, DbU::Unit height, DbU::Unit width )
|
HVBoxSet::HVBoxSet ( const vector<BoxSet*>& dimensionSet, DbU::Unit height, DbU::Unit width )
|
||||||
: BoxSet(height,width)
|
: BoxSet(height,width)
|
||||||
,_dimensionSet(dimensionSet)
|
,_dimensionSet(dimensionSet)
|
||||||
{ }
|
{
|
||||||
|
for ( BoxSet* bs : _dimensionSet ) bs->incrementCpt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HVBoxSet::HVBoxSet ( HVBoxSet* boxSet )
|
HVBoxSet::HVBoxSet ( HVBoxSet* boxSet )
|
||||||
: BoxSet( boxSet )
|
: BoxSet( boxSet )
|
||||||
, _dimensionSet( boxSet->getSet() )
|
, _dimensionSet( boxSet->getSet() )
|
||||||
{ }
|
{
|
||||||
|
for ( BoxSet* bs : _dimensionSet ) bs->incrementCpt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HVBoxSet::~HVBoxSet ()
|
HVBoxSet::~HVBoxSet ()
|
||||||
|
@ -133,6 +155,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string HVBoxSet::_getTypeName () const
|
||||||
|
{ return "HVBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::HBoxSet".
|
// Class : "Bora::HBoxSet".
|
||||||
|
|
||||||
|
@ -199,6 +225,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string HBoxSet::_getTypeName () const
|
||||||
|
{ return "HBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::VBoxSet".
|
// Class : "Bora::VBoxSet".
|
||||||
|
|
||||||
|
@ -266,6 +296,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string VBoxSet::_getTypeName () const
|
||||||
|
{ return "VBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::DBoxSet".
|
// Class : "Bora::DBoxSet".
|
||||||
|
|
||||||
|
@ -338,6 +372,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string DBoxSet::_getTypeName () const
|
||||||
|
{ return "DBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::RHVBoxSet".
|
// Class : "Bora::RHVBoxSet".
|
||||||
|
|
||||||
|
@ -379,6 +417,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string RHVBoxSet::_getTypeName () const
|
||||||
|
{ return "RHVBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::RHBoxSet".
|
// Class : "Bora::RHBoxSet".
|
||||||
|
|
||||||
|
@ -412,6 +454,10 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string RHBoxSet::_getTypeName () const
|
||||||
|
{ return "RHBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Class : "Bora::RVBoxSet".
|
// Class : "Bora::RVBoxSet".
|
||||||
|
|
||||||
|
@ -445,4 +491,8 @@ namespace Bora {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string RVBoxSet::_getTypeName () const
|
||||||
|
{ return "RVBoxSet"; }
|
||||||
|
|
||||||
|
|
||||||
} // Bora namespace.
|
} // Bora namespace.
|
||||||
|
|
|
@ -699,7 +699,7 @@ namespace Bora {
|
||||||
} else {
|
} else {
|
||||||
vector<BoxSet*>::const_iterator ibs = boxSet->getSet().begin();
|
vector<BoxSet*>::const_iterator ibs = boxSet->getSet().begin();
|
||||||
for ( VSlicingNodes::iterator ichild = _children.begin()
|
for ( VSlicingNodes::iterator ichild = _children.begin()
|
||||||
; ichild != _children.end(); ichild++){
|
; ichild != _children.end(); ichild++) {
|
||||||
(*ichild)->_setGlobalSize( *ibs );
|
(*ichild)->_setGlobalSize( *ibs );
|
||||||
ibs++;
|
ibs++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,6 +334,7 @@ namespace Bora {
|
||||||
if (find(boxSet) == NULL) _boxSets.push_back( boxSet );
|
if (find(boxSet) == NULL) _boxSets.push_back( boxSet );
|
||||||
else {
|
else {
|
||||||
find( boxSet )->incrementCpt();
|
find( boxSet )->incrementCpt();
|
||||||
|
cerr << "NodeSets::push_back(): do not add current BoxSet, already exists." << endl;
|
||||||
boxSet->destroy();
|
boxSet->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,8 @@ namespace Bora {
|
||||||
virtual double getDevicesArea () const = 0;
|
virtual double getDevicesArea () const = 0;
|
||||||
virtual void setHeight ( DbU::Unit );
|
virtual void setHeight ( DbU::Unit );
|
||||||
virtual void setWidth ( DbU::Unit );
|
virtual void setWidth ( DbU::Unit );
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
|
virtual std::string _getString () const;
|
||||||
protected:
|
protected:
|
||||||
DbU::Unit _height;
|
DbU::Unit _height;
|
||||||
DbU::Unit _width;
|
DbU::Unit _width;
|
||||||
|
@ -106,7 +108,7 @@ namespace Bora {
|
||||||
double getDevicesArea () const;
|
double getDevicesArea () const;
|
||||||
virtual inline void calculateHeight () = 0;
|
virtual inline void calculateHeight () = 0;
|
||||||
virtual inline void calculateWidth () = 0;
|
virtual inline void calculateWidth () = 0;
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
protected:
|
protected:
|
||||||
std::vector<BoxSet*> _dimensionSet;
|
std::vector<BoxSet*> _dimensionSet;
|
||||||
};
|
};
|
||||||
|
@ -136,6 +138,7 @@ namespace Bora {
|
||||||
static inline void printCount ();
|
static inline void printCount ();
|
||||||
static inline void printCountAll ();
|
static inline void printCountAll ();
|
||||||
void destroy ();
|
void destroy ();
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
private:
|
private:
|
||||||
static int _count;
|
static int _count;
|
||||||
static int _countAll;
|
static int _countAll;
|
||||||
|
@ -168,6 +171,7 @@ namespace Bora {
|
||||||
static inline void printCount ();
|
static inline void printCount ();
|
||||||
static inline void printCountAll ();
|
static inline void printCountAll ();
|
||||||
void destroy ();
|
void destroy ();
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
private:
|
private:
|
||||||
static int _count;
|
static int _count;
|
||||||
static int _countAll;
|
static int _countAll;
|
||||||
|
@ -201,6 +205,7 @@ namespace Bora {
|
||||||
static inline void printCount ();
|
static inline void printCount ();
|
||||||
static inline void printCountAll ();
|
static inline void printCountAll ();
|
||||||
void destroy ();
|
void destroy ();
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
private:
|
private:
|
||||||
size_t _index;
|
size_t _index;
|
||||||
static int _count;
|
static int _count;
|
||||||
|
@ -238,6 +243,7 @@ namespace Bora {
|
||||||
virtual void setHeight ( DbU::Unit height ) { _height = 0; };
|
virtual void setHeight ( DbU::Unit height ) { _height = 0; };
|
||||||
virtual void setWidth ( DbU::Unit width ) { _width = 0; };
|
virtual void setWidth ( DbU::Unit width ) { _width = 0; };
|
||||||
void print () const;
|
void print () const;
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
protected:
|
protected:
|
||||||
static int _count;
|
static int _count;
|
||||||
static int _countAll;
|
static int _countAll;
|
||||||
|
@ -260,13 +266,14 @@ namespace Bora {
|
||||||
class RHBoxSet: public RHVBoxSet
|
class RHBoxSet: public RHVBoxSet
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
RHBoxSet ( DbU::Unit height=0 );
|
RHBoxSet ( DbU::Unit height=0 );
|
||||||
RHBoxSet ( RHBoxSet* );
|
RHBoxSet ( RHBoxSet* );
|
||||||
~RHBoxSet ();
|
~RHBoxSet ();
|
||||||
public:
|
public:
|
||||||
static RHBoxSet* create ( DbU::Unit height );
|
static RHBoxSet* create ( DbU::Unit height );
|
||||||
RHBoxSet* clone ();
|
RHBoxSet* clone ();
|
||||||
inline void setHeight ( DbU::Unit height );
|
inline void setHeight ( DbU::Unit height );
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,13 +287,14 @@ namespace Bora {
|
||||||
class RVBoxSet: public RHVBoxSet
|
class RVBoxSet: public RHVBoxSet
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
RVBoxSet ( DbU::Unit width=0 );
|
RVBoxSet ( DbU::Unit width=0 );
|
||||||
RVBoxSet ( RVBoxSet* boxSet );
|
RVBoxSet ( RVBoxSet* boxSet );
|
||||||
~RVBoxSet ();
|
~RVBoxSet ();
|
||||||
public:
|
public:
|
||||||
static RVBoxSet* create ( DbU::Unit width );
|
static RVBoxSet* create ( DbU::Unit width );
|
||||||
RVBoxSet* clone ();
|
RVBoxSet* clone ();
|
||||||
inline void setWidth ( DbU::Unit width );
|
inline void setWidth ( DbU::Unit width );
|
||||||
|
virtual std::string _getTypeName () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,4 +321,38 @@ namespace Bora {
|
||||||
|
|
||||||
} // Bora namespace.
|
} // 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
|
#endif // BORA_BOX_SET_H
|
||||||
|
|
Loading…
Reference in New Issue