Merge pull request #767 from KLayout/bugfixes

Bugfixes
This commit is contained in:
Matthias Köfferlein 2021-04-11 22:42:01 +02:00 committed by GitHub
commit 09e72d0507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 261 additions and 18 deletions

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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
*/

View File

@ -357,10 +357,7 @@ CompoundRegionMultiInputOperationNode::init ()
CompoundRegionMultiInputOperationNode::~CompoundRegionMultiInputOperationNode ()
{
for (tl::shared_collection<CompoundRegionOperationNode>::iterator i = m_children.begin (); i != m_children.end (); ++i) {
delete i.operator-> ();
}
m_children.clear ();
// .. nothing yet ..
}
void

View File

@ -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
*

View File

@ -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];

View File

@ -558,7 +558,7 @@ public:
virtual void process (const db::Polygon &poly, std::vector<db::Polygon> &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<db::Polygon> &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; }

View File

@ -206,6 +206,18 @@ public:
}
}
/**
* @brief The move constructor
*/
user_object (user_object<C> &&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<C> &operator= (user_object<C> &&d)
{
if (d.mp_obj) {
set_ptr (d.mp_obj);
d.mp_obj = 0;
} else {
set_ptr (0);
}
return *this;
}
/**
* @brief The destructor
*/

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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<AnnotationLayerOp *> (op);

View File

@ -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
*

View File

@ -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 ();

View File

@ -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 {

View File

@ -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

View File

@ -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
*

View File

@ -60,6 +60,11 @@ public:
*/
explicit vector (const tl::vector<T> &d) : base (d) { }
/**
* @brief Move constructor
*/
explicit vector (const tl::vector<T> &&d) : base (d) { }
/**
* @brief Assignment
*/
@ -71,6 +76,17 @@ public:
return *this;
}
/**
* @brief Assignment (Move)
*/
vector &operator= (const tl::vector<T> &&d)
{
if (&d != this) {
base::operator= (d);
}
return *this;
}
/**
* @brief Initialization with value and length
*/