IMPORTANT BUGFIX: array repo handling

The issue: when cloning an array, the
"in_repository" flag might be left set. This
makes the system think the array is kept in
a repo. In the best case this creates a
memory leak.
This commit is contained in:
Matthias Koefferlein 2019-01-05 21:55:06 +01:00
parent 6e468b43e0
commit 15b79c9ddb
3 changed files with 38 additions and 1 deletions

View File

@ -87,6 +87,17 @@ struct ArrayBase
// .. nothing yet ..
}
ArrayBase (const ArrayBase &)
: in_repository (false)
{
// .. nothing yet ..
}
ArrayBase &operator= (const ArrayBase &)
{
return *this;
}
virtual ~ArrayBase ()
{
// .. nothing yet ..

View File

@ -323,7 +323,7 @@ CellMapping::create_missing_mapping (db::Layout &layout_a, db::cell_index_type /
db::CellInstArray bci = bi.cell_inst ();
bci.object ().cell_index (new_cells [i]);
bci.transform_into (db::ICplxTrans (mag));
bci.transform_into (db::ICplxTrans (mag), &layout_a.array_repository ());
if (bi.has_prop_id ()) {
pa.insert (db::CellInstArrayWithProperties (bci, pm (bi.prop_id ())));

View File

@ -427,3 +427,29 @@ TEST(5)
EXPECT_EQ (l2s (hh), "a0top#0:cell_index=4 r90 0,0 array=(0,10,10,0 5x1),cell_index=5 r90 0,0 array=(0,10,10,0 5x2),cell_index=1 r0 10,0,cell_index=6 r90 0,0 array=(0,20,20,0 5x2),cell_index=7 r90 0,0 array=(0,20,20,0 5x2);a1#1:cell_index=2 r0 0,0,cell_index=2 r0 0,20,cell_index=3 r0 0,40;a2#2:cell_index=3 r0 0,0,cell_index=3 r0 0,10;a3#3:cell_index=4 r90 0,0;a4#4:;a5#5:;a4$1#6:;a5$1#7:");
}
// Resolution of array references
TEST(6)
{
std::auto_ptr<db::Layout> g (new db::Layout ());
db::Cell &a0 (g->cell (g->add_cell ("a0")));
db::Cell *a4p, *a5p;
a4p = &(g->cell (g->add_cell ("a4")));
a5p = &(g->cell (g->add_cell ("a5")));
db::Cell &a4 (*a4p);
db::Cell &a5 (*a5p);
a0.insert (db::CellInstArray (db::CellInst (a4.cell_index ()), db::Trans (1/*r90*/), g->array_repository (), db::Vector(0, 10), db::Vector(10, 0), 5, 2));
a0.insert (db::CellInstArray (db::CellInst (a5.cell_index ()), db::Trans (1/*r90*/), g->array_repository (), db::Vector(0, 10), db::Vector(10, 0), 5, 2));
db::Layout h;
db::Cell &b0 (h.cell (h.add_cell ("a0top")));
db::CellMapping cm;
cm.create_single_mapping_full (h, b0.cell_index (), *g, a0.cell_index ());
EXPECT_EQ (m2s (cm, *g, h), "a0->a0top;a4->a4;a5->a5");
g.reset (0);
EXPECT_EQ (l2s (h), "a0top#0:cell_index=1 r90 0,0 array=(0,10,10,0 5x2),cell_index=2 r90 0,0 array=(0,10,10,0 5x2);a4#1:;a5#2:");
}