From 85869c329d0b4abf2f744df3bf3f583aa3e7bc8e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 3 Nov 2020 00:13:28 +0100 Subject: [PATCH] BUGFIX: db::Shapes::insert(db::Shapes) wasn't working correctly! --- src/db/db/dbShapes.cc | 12 +++++++++--- src/db/db/dbShapes.h | 1 + src/db/db/dbShapes2.cc | 8 ++++++++ src/db/db/dbShapes2.h | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index aef79fa21..dedd81cb2 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -174,9 +174,15 @@ Shapes::do_insert (const Shapes &d) if (layout () == d.layout ()) { // both shape containers reside in the same repository space - simply copy - m_layers.reserve (d.m_layers.size ()); - for (tl::vector::const_iterator l = d.m_layers.begin (); l != d.m_layers.end (); ++l) { - m_layers.push_back ((*l)->clone (this, manager ())); + if (m_layers.empty ()) { + m_layers.reserve (d.m_layers.size ()); + for (tl::vector::const_iterator l = d.m_layers.begin (); l != d.m_layers.end (); ++l) { + m_layers.push_back ((*l)->clone (this, manager ())); + } + } else { + for (tl::vector::const_iterator l = d.m_layers.begin (); l != d.m_layers.end (); ++l) { + (*l)->insert_into (this); + } } } else if (layout () == 0) { diff --git a/src/db/db/dbShapes.h b/src/db/db/dbShapes.h index 1942906a0..6f7dcbb20 100644 --- a/src/db/db/dbShapes.h +++ b/src/db/db/dbShapes.h @@ -493,6 +493,7 @@ public: virtual void transform_into (Shapes *target, const Trans &trans, GenericRepository &rep, ArrayRepository &array_rep, pm_delegate_type &pm) const = 0; virtual void transform_into (Shapes *target, const ICplxTrans &trans, GenericRepository &rep, ArrayRepository &array_rep) const = 0; virtual void transform_into (Shapes *target, const ICplxTrans &trans, GenericRepository &rep, ArrayRepository &array_rep, pm_delegate_type &pm) const = 0; + virtual void insert_into (Shapes *target) = 0; virtual void deref_into (Shapes *target) = 0; virtual void deref_into (Shapes *target, pm_delegate_type &pm) = 0; virtual void deref_and_transform_into (Shapes *target, const Trans &trans) = 0; diff --git a/src/db/db/dbShapes2.cc b/src/db/db/dbShapes2.cc index 73fd33aad..19396588e 100644 --- a/src/db/db/dbShapes2.cc +++ b/src/db/db/dbShapes2.cc @@ -834,6 +834,13 @@ layer_class::transform_into (Shapes *target, const ICplxTrans &tr } } +template +void +layer_class::insert_into (Shapes *target) +{ + target->insert (m_layer.begin (), m_layer.end ()); +} + template void layer_class::deref_into (Shapes *target) @@ -870,6 +877,7 @@ layer_class::deref_and_transform_into (Shapes *target, const Tran { deref_and_transform_into_shapes deref_op (target); for (typename layer_type::iterator s = m_layer.begin (); s != m_layer.end (); ++s) { + deref_op (*s, trans, pm); } } diff --git a/src/db/db/dbShapes2.h b/src/db/db/dbShapes2.h index d60678e28..7c7d3ba60 100644 --- a/src/db/db/dbShapes2.h +++ b/src/db/db/dbShapes2.h @@ -149,6 +149,7 @@ public: virtual void transform_into (Shapes *target, const Trans &trans, GenericRepository &rep, ArrayRepository &array_rep, pm_delegate_type &pm) const; virtual void transform_into (Shapes *target, const ICplxTrans &trans, GenericRepository &rep, ArrayRepository &array_rep) const; virtual void transform_into (Shapes *target, const ICplxTrans &trans, GenericRepository &rep, ArrayRepository &array_rep, pm_delegate_type &pm) const; + virtual void insert_into (Shapes *target); virtual void deref_into (Shapes *target); virtual void deref_into (Shapes *target, pm_delegate_type &pm); virtual void deref_and_transform_into (Shapes *target, const Trans &trans);