mirror of https://github.com/KLayout/klayout.git
[consider merging] avoid a crash during certain queries
This query used to crash: "instances of cell .*.* where inst.trans.rot == 2" on a layout with 1 hierarchy level and some cells with rot 180 degree
This commit is contained in:
parent
0e4594c0c3
commit
850a6f56d3
|
|
@ -1006,15 +1006,19 @@ public:
|
|||
|
||||
db::Instance inst;
|
||||
if (m_reading) {
|
||||
inst = mp_parent->sorted_inst_ptr (std::distance (mp_parent->begin_sorted_insts (), m_inst));
|
||||
if (mp_parent) {
|
||||
inst = mp_parent->sorted_inst_ptr (std::distance (mp_parent->begin_sorted_insts (), m_inst));
|
||||
}
|
||||
} else {
|
||||
inst = m_i;
|
||||
}
|
||||
|
||||
if (m_instance_mode == ArrayInstances) {
|
||||
v.push (tl::Variant (db::InstElement (inst)));
|
||||
} else {
|
||||
v.push (tl::Variant (db::InstElement (inst, m_array_iter)));
|
||||
if (! inst.is_null ()) {
|
||||
if (m_instance_mode == ArrayInstances) {
|
||||
v.push (tl::Variant (db::InstElement (inst)));
|
||||
} else {
|
||||
v.push (tl::Variant (db::InstElement (inst, m_array_iter)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1578,3 +1578,20 @@ TEST(64)
|
|||
EXPECT_EQ (s, "(0.01,-0.02),(-0.01,0.02),(-0.01,0.02),(-0.01,0.02),(0.01,-0.02),(-0.01,0.02)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(65)
|
||||
{
|
||||
db::Layout g;
|
||||
init_layout (g);
|
||||
|
||||
{
|
||||
db::LayoutQuery q ("instances of cell .*.* where inst.trans.rot == 0");
|
||||
db::LayoutQueryIterator iq (q, &g);
|
||||
std::string s = q2s_var (iq, "data");
|
||||
EXPECT_EQ (s, "nil,nil");
|
||||
s = q2s_var (iq, "cell_name");
|
||||
EXPECT_EQ (s, "c1,c5x");
|
||||
s = q2s_var (iq, "inst_elements");
|
||||
EXPECT_EQ (s, "(cell_index=0 r0 *1 10,-20),(cell_index=4 r0 *1 10,-20)");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue