From 6f583b1b21f28601486e55b99f2a0931faa59a22 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 12 Jun 2021 09:45:02 +0200 Subject: [PATCH 1/2] Fixed #835 --- src/db/db/dbShapes.cc | 2 +- src/db/unit_tests/dbShapesTests.cc | 60 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index 42c770c32..0c3ce4438 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -384,7 +384,7 @@ Shapes::do_insert (const Shapes::shape_type &shape, const Shapes::unit_trans_typ if (shape.text_ref ().obj ().string_ref () != 0) { return safe_insert_text (*this, shape, pm); } else { - return (insert_by_tag (shape_type::text_ref_type::tag (), shape, pm)); + return (insert_by_tag (shape_type::text_ref_type::tag (), shape, shape_repository (), pm)); } } case shape_type::TextPtrArrayMember: diff --git a/src/db/unit_tests/dbShapesTests.cc b/src/db/unit_tests/dbShapesTests.cc index cb46ea589..4c1044af4 100644 --- a/src/db/unit_tests/dbShapesTests.cc +++ b/src/db/unit_tests/dbShapesTests.cc @@ -3262,3 +3262,63 @@ TEST(100) ); } +// Bug #835 +TEST(101) +{ + db::Layout a, b; + + unsigned int la = a.insert_layer (); + db::cell_index_type topa = a.add_cell ("TOP"); + db::Shapes &sa = a.cell (topa).shapes (la); + + unsigned int lb = b.insert_layer (); + db::cell_index_type topb = b.add_cell ("TOP"); + db::Shapes &sb = b.cell (topb).shapes (lb); + + db::TextRef tr (db::Text ("TEXT", db::Trans ()), a.shape_repository ()); + + db::PolygonRef pr (db::Polygon (db::Box (0, 0, 100, 200)), a.shape_repository ()); + + db::Point pp[] = { db::Point (0, 0), db::Point (100, 200) }; + db::PathRef qr (db::Path (&pp[0], &pp[0] + 2, 20), a.shape_repository ()); + + db::Shape st = sa.insert (tr); + db::Shape sp = sa.insert (pr); + db::Shape sq = sa.insert (qr); + + // text sits in "a" shape repo now. + db::TextRef tr1 = st.text_ref (); + const db::Text &tr1_obj = *a.shape_repository ().repository (db::Text::tag ()).begin (); + EXPECT_EQ (& tr1.obj () == &tr1_obj, true); + + // polygon sits in "a" shape repo now. + db::PolygonRef pr1 = sp.polygon_ref (); + const db::Polygon &pr1_obj = *a.shape_repository ().repository (db::Polygon::tag ()).begin (); + EXPECT_EQ (& pr1.obj () == &pr1_obj, true); + + // path sits in "a" shape repo now. + db::PathRef qr1 = sq.path_ref (); + const db::Path &qr1_obj = *a.shape_repository ().repository (db::Path::tag ()).begin (); + EXPECT_EQ (& qr1.obj () == &qr1_obj, true); + + // Now insert into sb + + db::Shape st2 = sb.insert (st); + db::Shape sp2 = sb.insert (sp); + db::Shape sq2 = sb.insert (sq); + + // text sits in "b" shape repo now. + db::TextRef tr2 = st2.text_ref (); + const db::Text &tr2_obj = *b.shape_repository ().repository (db::Text::tag ()).begin (); + EXPECT_EQ (& tr2.obj () == &tr2_obj, true); + + // polygon sits in "b" shape repo now. + db::PolygonRef pr2 = sp2.polygon_ref (); + const db::Polygon &pr2_obj = *b.shape_repository ().repository (db::Polygon::tag ()).begin (); + EXPECT_EQ (& pr2.obj () == &pr2_obj, true); + + // path sits in "b" shape repo now. + db::PathRef qr2 = sq2.path_ref (); + const db::Path &qr2_obj = *b.shape_repository ().repository (db::Path::tag ()).begin (); + EXPECT_EQ (& qr2.obj () == &qr2_obj, true); +} From 3b22bc0a42469c20fd86ceae68b812f2e55ab841 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 12 Jun 2021 23:34:32 +0200 Subject: [PATCH 2/2] Fixed the fix: considering the case of non-layout hosted Shapes container too --- src/db/db/dbShapes.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index 0c3ce4438..7b4ddf96c 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -381,7 +381,15 @@ Shapes::do_insert (const Shapes::shape_type &shape, const Shapes::unit_trans_typ } case shape_type::TextRef: { - if (shape.text_ref ().obj ().string_ref () != 0) { + if (! layout ()) { + shape_type::text_type t; + shape.text (t); + if (! shape.has_prop_id ()) { + return insert (t); + } else { + return insert (db::object_with_properties (t, pm (shape.prop_id ()))); + } + } else if (shape.text_ref ().obj ().string_ref () != 0) { return safe_insert_text (*this, shape, pm); } else { return (insert_by_tag (shape_type::text_ref_type::tag (), shape, shape_repository (), pm));