diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 721cd8c24..98bb0fcd5 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -122,7 +122,6 @@ PropertiesPage::swap_points_clicked () y1->setText (ty1); y2->setText (ty2); - db::Transaction t (manager (), tl::to_string (QObject::tr ("Swap ruler points"))); emit edited (); } @@ -224,7 +223,6 @@ PropertiesPage::snap_to_layout_clicked () y2->setText (ys); } - db::Transaction t (manager (), tl::to_string (snap_p1 ? QObject::tr ("Snap first ruler point") : QObject::tr ("Snap second ruler point"))); emit edited (); break; @@ -249,7 +247,6 @@ PropertiesPage::snap_to_layout_clicked () x2->setText (tl::to_qstring (tl::micron_to_string (ee.second.x ()))); y2->setText (tl::to_qstring (tl::micron_to_string (ee.second.y ()))); - db::Transaction t (manager (), tl::to_string (QObject::tr ("Snap both ruler points"))); emit edited (); } diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index e5d74cef7..f9666fd2c 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -1274,8 +1274,9 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) // compute moved object and replace ant::Object *rnew = new ant::Object (*robj); rnew->transform (m_trans); + int new_id = rnew->id (); mp_view->annotation_shapes ().replace (s->first, db::DUserObject (rnew)); - annotation_changed_event (rnew->id ()); + annotation_changed_event (new_id); } diff --git a/src/db/db/dbBoxTree.h b/src/db/db/dbBoxTree.h index acd9c37a2..cc687ca54 100644 --- a/src/db/db/dbBoxTree.h +++ b/src/db/db/dbBoxTree.h @@ -760,6 +760,15 @@ public: // .. nothing else .. } + /** + * @brief Move constructor + */ + box_tree (box_tree &&b) + : m_objects (b.m_objects), m_elements (b.m_elements), mp_root (b.mp_root) + { + b.mp_root = 0; + } + /** * @brief Assignment */ @@ -774,6 +783,21 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + box_tree &operator= (box_tree &&b) + { + clear (); + m_objects = b.m_objects; + m_elements = b.m_elements; + if (b.mp_root) { + mp_root = b.mp_root; + b.mp_root = 0; + } + return *this; + } + /** * @brief The destructor */ @@ -1729,6 +1753,15 @@ public: // .. nothing else .. } + /** + * @brief Move constructor + */ + unstable_box_tree (unstable_box_tree &&b) + : m_objects (b.m_objects), mp_root (b.mp_root) + { + b.mp_root = 0; + } + /** * @brief Assignment */ @@ -1742,6 +1775,20 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + unstable_box_tree &operator= (unstable_box_tree &&b) + { + clear (); + m_objects = b.m_objects; + if (b.mp_root) { + mp_root = b.mp_root; + b.mp_root = 0; + } + return *this; + } + /** * @brief The destructor */ diff --git a/src/db/db/dbCompoundOperation.cc b/src/db/db/dbCompoundOperation.cc index db4aedd84..e3e9b8d7c 100644 --- a/src/db/db/dbCompoundOperation.cc +++ b/src/db/db/dbCompoundOperation.cc @@ -357,10 +357,7 @@ CompoundRegionMultiInputOperationNode::init () CompoundRegionMultiInputOperationNode::~CompoundRegionMultiInputOperationNode () { - for (tl::shared_collection::iterator i = m_children.begin (); i != m_children.end (); ++i) { - delete i.operator-> (); - } - m_children.clear (); + // .. nothing yet .. } void diff --git a/src/db/db/dbLayer.h b/src/db/db/dbLayer.h index 2f54619f6..453c8648f 100644 --- a/src/db/db/dbLayer.h +++ b/src/db/db/dbLayer.h @@ -107,6 +107,14 @@ struct layer operator= (d); } + /** + * @brief The move constructor + */ + layer (const layer &&d) + { + operator= (d); + } + /** * @brief The assignment operator * @@ -123,6 +131,20 @@ struct layer return *this; } + /** + * @brief The assignment operator (move semantics) + */ + layer &operator= (const layer &&d) + { + if (&d != this) { + m_box_tree = d.m_box_tree; + m_bbox = d.m_bbox; + m_bbox_dirty = d.m_bbox_dirty; + m_tree_dirty = d.m_tree_dirty; + } + return *this; + } + /** * @brief Get the iterator for an object given by a pointer */ @@ -207,6 +229,18 @@ struct layer return m_box_tree.insert (sh); } + /** + * @brief Insert a new shape object (move semantics) + */ + iterator insert (const Sh &&sh) + { + // inserting will make the bbox and the tree "dirty" - i.e. + // it will need to be updated. + m_bbox_dirty = true; + m_tree_dirty = true; + return m_box_tree.insert (sh); + } + /** * @brief Replace the given element with a new one * @@ -228,6 +262,19 @@ struct layer return *ncpos; } + /** + * @brief Replace the given element with a new one (move semantics) + */ + Sh &replace (iterator pos, const Sh &&sh) + { + m_bbox_dirty = true; + m_tree_dirty = true; + non_const_iterator ncpos; + to_non_const_box_tree_iter (pos, ncpos, StableTag ()); + *ncpos = sh; + return *ncpos; + } + /** * @brief Erasing of an element * diff --git a/src/db/db/dbPolygonTools.cc b/src/db/db/dbPolygonTools.cc index 808133e68..6d37ab289 100644 --- a/src/db/db/dbPolygonTools.cc +++ b/src/db/db/dbPolygonTools.cc @@ -1626,7 +1626,7 @@ AreaMap::reinitialize (const db::Point &p0, const db::Vector &d, const db::Vecto m_ny = ny; if (mp_av) { - delete mp_av; + delete[] mp_av; } mp_av = new area_type [nx * ny]; diff --git a/src/db/db/dbRegionUtils.h b/src/db/db/dbRegionUtils.h index f1da9196d..a7e67ce61 100644 --- a/src/db/db/dbRegionUtils.h +++ b/src/db/db/dbRegionUtils.h @@ -558,7 +558,7 @@ public: virtual void process (const db::Polygon &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return 0; } - virtual bool result_is_merged () const { return true; } // we believe so ... + virtual bool result_is_merged () const { return false; } // isn't merged for nested holes :( virtual bool requires_raw_input () const { return false; } virtual bool wants_variants () const { return true; } virtual bool result_must_not_be_merged () const { return false; } @@ -577,7 +577,7 @@ public: virtual void process (const db::Polygon &poly, std::vector &res) const; virtual const TransformationReducer *vars () const { return 0; } - virtual bool result_is_merged () const { return true; } // we believe so ... + virtual bool result_is_merged () const { return false; } // isn't merged for nested hulls :( virtual bool requires_raw_input () const { return false; } virtual bool wants_variants () const { return true; } virtual bool result_must_not_be_merged () const { return false; } diff --git a/src/db/db/dbUserObject.h b/src/db/db/dbUserObject.h index 8961480ba..f9a3c0b92 100644 --- a/src/db/db/dbUserObject.h +++ b/src/db/db/dbUserObject.h @@ -206,6 +206,18 @@ public: } } + /** + * @brief The move constructor + */ + user_object (user_object &&d) + : mp_obj (0) + { + if (d.mp_obj) { + set_ptr (d.mp_obj); + d.mp_obj = 0; + } + } + /** * @brief Assignment operator */ @@ -219,6 +231,20 @@ public: return *this; } + /** + * @brief Assignment operator (move) + */ + user_object &operator= (user_object &&d) + { + if (d.mp_obj) { + set_ptr (d.mp_obj); + d.mp_obj = 0; + } else { + set_ptr (0); + } + return *this; + } + /** * @brief The destructor */ diff --git a/src/db/unit_tests/dbCompoundOperationTests.cc b/src/db/unit_tests/dbCompoundOperationTests.cc index a465fc28f..a0d305afa 100644 --- a/src/db/unit_tests/dbCompoundOperationTests.cc +++ b/src/db/unit_tests/dbCompoundOperationTests.cc @@ -99,6 +99,7 @@ void run_test1 (tl::TestBase *_this, bool deep) unsigned int l1002 = ly.get_layer (db::LayerProperties (1002, 0)); res.insert_into (&ly, *ly.begin_top_down (), l1002); + primary = new db::CompoundRegionOperationPrimaryNode (); db::CompoundRegionCheckOperationNode space_check (primary, db::SpaceRelation, false /*==all polygons*/, 1050, check_options); res = r.cop_to_edge_pairs (space_check); diff --git a/src/db/unit_tests/dbDeepRegionTests.cc b/src/db/unit_tests/dbDeepRegionTests.cc index 46b57bf22..f02a2f1db 100644 --- a/src/db/unit_tests/dbDeepRegionTests.cc +++ b/src/db/unit_tests/dbDeepRegionTests.cc @@ -694,8 +694,8 @@ TEST(10_HullsAndHoles) db::Region hulls = r1_sized.hulls (); db::Region holes = r1_sized.holes (); - EXPECT_EQ (hulls.is_merged (), true); - EXPECT_EQ (holes.is_merged (), true); + EXPECT_EQ (hulls.is_merged (), false); + EXPECT_EQ (holes.is_merged (), false); db::Layout target; unsigned int target_top_cell_index = target.add_cell (ly.cell_name (top_cell_index)); diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index 2360211db..4034061fe 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -542,6 +542,9 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & try { tl::from_string (tl::to_string (rows_le->text ()), rows); + if (rows < 1) { + throw tl::Exception (tl::to_string (tr ("Rows count can't be zero"))); + } lay::indicate_error (rows_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (rows_le, &ex); @@ -550,6 +553,9 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance & try { tl::from_string (tl::to_string (columns_le->text ()), cols); + if (cols < 1) { + throw tl::Exception (tl::to_string (tr ("Columns count can't be zero"))); + } lay::indicate_error (columns_le, (tl::Exception *) 0); } catch (tl::Exception &ex) { lay::indicate_error (columns_le, &ex); diff --git a/src/laybasic/laybasic/layAnnotationShapes.cc b/src/laybasic/laybasic/layAnnotationShapes.cc index c7babddd1..10a43b865 100644 --- a/src/laybasic/laybasic/layAnnotationShapes.cc +++ b/src/laybasic/laybasic/layAnnotationShapes.cc @@ -89,6 +89,12 @@ AnnotationShapes::AnnotationShapes (const AnnotationShapes &d) operator= (d); } +AnnotationShapes::AnnotationShapes (const AnnotationShapes &&d) + : db::LayoutStateModel (true /*busy*/), db::Object (d) +{ + operator= (d); +} + AnnotationShapes::~AnnotationShapes () { clear (); @@ -106,7 +112,21 @@ AnnotationShapes::operator= (const AnnotationShapes &d) } return *this; } -void + +AnnotationShapes & +AnnotationShapes::operator= (const AnnotationShapes &&d) +{ + if (&d != this) { + clear (); + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, d.m_layer.begin (), d.m_layer.end ())); + } + m_layer = d.m_layer; + } + return *this; +} + +void AnnotationShapes::clear () { if (manager () && manager ()->transacting ()) { @@ -126,7 +146,17 @@ AnnotationShapes::insert (const shape_type &sh) return *m_layer.insert (sh); } -void +const AnnotationShapes::shape_type & +AnnotationShapes::insert (const shape_type &&sh) +{ + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, sh)); + } + invalidate_state (); // HINT: must come before the change is done! + return *m_layer.insert (sh); +} + +void AnnotationShapes::reserve (size_t n) { m_layer.reserve (n); @@ -156,7 +186,21 @@ AnnotationShapes::replace (iterator pos, const shape_type &sh) return *pos; } -void +const AnnotationShapes::shape_type & +AnnotationShapes::replace (iterator pos, const shape_type &&sh) +{ + if (&*pos != &sh && *pos != sh) { + if (manager () && manager ()->transacting ()) { + manager ()->queue (this, new AnnotationLayerOp (false /*not insert*/, *pos)); + manager ()->queue (this, new AnnotationLayerOp (true /*insert*/, sh)); + } + invalidate_state (); // HINT: must come before the change is done! + m_layer.replace (pos, sh); + } + return *pos; +} + +void AnnotationShapes::redo (db::Op *op) { AnnotationLayerOp *layop = dynamic_cast (op); diff --git a/src/laybasic/laybasic/layAnnotationShapes.h b/src/laybasic/laybasic/layAnnotationShapes.h index f715c8597..c60abb5e5 100644 --- a/src/laybasic/laybasic/layAnnotationShapes.h +++ b/src/laybasic/laybasic/layAnnotationShapes.h @@ -135,16 +135,37 @@ public: */ AnnotationShapes (const AnnotationShapes &d); + /** + * @brief Copy ctor + */ + AnnotationShapes (const AnnotationShapes &&d); + /** * @brief Assignment operator */ AnnotationShapes &operator= (const AnnotationShapes &d); + /** + * @brief Assignment operator (move) + */ + AnnotationShapes &operator= (const AnnotationShapes &&d); + /** * @brief Insert a shape_type */ const shape_type &insert (const shape_type &sh); + /** + * @brief Insert a sequence of DUserObject shapes + * + * Inserts a sequence of shapes [from,to) + */ + + /** + * @brief Insert a shape_type (move semantics) + */ + const shape_type &insert (const shape_type &&sh); + /** * @brief Insert a sequence of DUserObject shapes * @@ -212,6 +233,11 @@ public: */ const shape_type &replace (iterator pos, const shape_type &sh); + /** + * @brief Replace an element at the given position with another shape (move semantics) + */ + const shape_type &replace (iterator pos, const shape_type &&sh); + /** * @brief updates the bbox * diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index c63bcade2..2a74de56c 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -1027,6 +1027,8 @@ NetlistBrowserPage::adjust_view () ebox += bbox_for_device_abstract (layout, a->device_abstract, a->trans); } + trans *= device->trans (); + } else if (net) { db::cell_index_type cell_index = net->circuit ()->cell_index (); diff --git a/src/laybasic/laybasic/layPropertiesDialog.cc b/src/laybasic/laybasic/layPropertiesDialog.cc index ddd8b0390..6aa420e11 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.cc +++ b/src/laybasic/laybasic/layPropertiesDialog.cc @@ -265,7 +265,7 @@ PropertiesDialog::apply () { BEGIN_PROTECTED - db::Transaction t (mp_manager, tl::to_string (QObject::tr ("Auto-apply changes")), m_transaction_id); + db::Transaction t (mp_manager, tl::to_string (QObject::tr ("Apply changes")), m_transaction_id); try { diff --git a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc index 8d974cb6d..ae3a6dfb7 100644 --- a/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc +++ b/src/plugins/streamers/gds2/db_plugin/dbGDS2Reader.cc @@ -206,7 +206,13 @@ GDS2Reader::get_string () void GDS2Reader::get_string (std::string &s) const { - s.assign ((const char *) mp_rec_buf, 0, m_reclen); + if (m_reclen == 0) { + s.clear (); + } else if (mp_rec_buf [m_reclen - 1] != 0) { + s.assign ((const char *) mp_rec_buf, m_reclen); + } else { + s.assign ((const char *) mp_rec_buf, m_reclen - 1); + } } void diff --git a/src/tl/tl/tlReuseVector.h b/src/tl/tl/tlReuseVector.h index 5a2eb6435..d9ff78cda 100644 --- a/src/tl/tl/tlReuseVector.h +++ b/src/tl/tl/tlReuseVector.h @@ -535,6 +535,19 @@ public: } } + /** + * @brief Move constructor + * + * See operator= for a description of the copy operation. + */ + reuse_vector (reuse_vector &&d) + { + mp_start = d.mp_start; d.mp_start = 0; + mp_finish = d.mp_finish; d.mp_finish = 0; + mp_capacity = d.mp_capacity; d.mp_capacity = 0; + mp_rdata = d.mp_rdata; d.mp_rdata = 0; + } + /** * @brief Destructor */ @@ -562,6 +575,20 @@ public: return *this; } + /** + * @brief Assignment (move) + */ + reuse_vector &operator= (reuse_vector &&d) + { + if (&d != this) { + mp_start = d.mp_start; d.mp_start = 0; + mp_finish = d.mp_finish; d.mp_finish = 0; + mp_capacity = d.mp_capacity; d.mp_capacity = 0; + mp_rdata = d.mp_rdata; d.mp_rdata = 0; + } + return *this; + } + /** * @brief Assignment * diff --git a/src/tl/tl/tlVector.h b/src/tl/tl/tlVector.h index b4ce0e5a1..0bbd77803 100644 --- a/src/tl/tl/tlVector.h +++ b/src/tl/tl/tlVector.h @@ -60,6 +60,11 @@ public: */ explicit vector (const tl::vector &d) : base (d) { } + /** + * @brief Move constructor + */ + explicit vector (const tl::vector &&d) : base (d) { } + /** * @brief Assignment */ @@ -71,6 +76,17 @@ public: return *this; } + /** + * @brief Assignment (Move) + */ + vector &operator= (const tl::vector &&d) + { + if (&d != this) { + base::operator= (d); + } + return *this; + } + /** * @brief Initialization with value and length */