mirror of https://github.com/KLayout/klayout.git
Merge pull request #1861 from KLayout/issue-1860
Fixed issue #1860 (problem with undo after delete layer)
This commit is contained in:
commit
304df2f107
|
|
@ -251,7 +251,7 @@ LayoutLayers::do_insert_layer (unsigned int index, bool special)
|
||||||
if (index >= layers ()) {
|
if (index >= layers ()) {
|
||||||
|
|
||||||
// add layer to the end of the list.
|
// add layer to the end of the list.
|
||||||
// add as may freelist entries as required.
|
// add as many freelist entries as required.
|
||||||
while (index > layers ()) {
|
while (index > layers ()) {
|
||||||
m_free_indices.push_back (layers ());
|
m_free_indices.push_back (layers ());
|
||||||
m_layer_states.push_back (Free);
|
m_layer_states.push_back (Free);
|
||||||
|
|
@ -263,6 +263,14 @@ LayoutLayers::do_insert_layer (unsigned int index, bool special)
|
||||||
tl_assert (m_layer_states [index] == Free);
|
tl_assert (m_layer_states [index] == Free);
|
||||||
m_layer_states [index] = special ? Special : Normal;
|
m_layer_states [index] = special ? Special : Normal;
|
||||||
|
|
||||||
|
// remove from the list of free indexes (issue #1860)
|
||||||
|
for (auto i = m_free_indices.begin (); i != m_free_indices.end (); ++i) {
|
||||||
|
if (*i == index) {
|
||||||
|
m_free_indices.erase (i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -871,3 +871,42 @@ TEST(11_FindPath)
|
||||||
std::string d = tl::join (path.begin (), path.end (), ";");
|
std::string d = tl::join (path.begin (), path.end (), ";");
|
||||||
EXPECT_EQ (d, "cell_index=1 r90 *1 0,0;cell_index=2 r0 *1 100,200");
|
EXPECT_EQ (d, "cell_index=1 r90 *1 0,0;cell_index=2 r0 *1 100,200");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue #1860
|
||||||
|
TEST(100_UndoOfDeleteLayer)
|
||||||
|
{
|
||||||
|
db::Manager m;
|
||||||
|
db::Layout l (&m);
|
||||||
|
db::Cell &top = l.cell (l.add_cell ("TOP"));
|
||||||
|
|
||||||
|
unsigned int li = 0, li2 = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
db::Transaction t (&m, "insert_layer");
|
||||||
|
li = l.insert_layer (db::LayerProperties (1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ (l.is_valid_layer (li), true);
|
||||||
|
|
||||||
|
{
|
||||||
|
db::Transaction t (&m, "remove_layer");
|
||||||
|
l.delete_layer (li);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ (l.is_valid_layer (li), false);
|
||||||
|
|
||||||
|
m.undo ();
|
||||||
|
|
||||||
|
EXPECT_EQ (l.is_valid_layer (li), true);
|
||||||
|
EXPECT_EQ (l.get_properties (li).to_string (), "1/0");
|
||||||
|
|
||||||
|
{
|
||||||
|
db::Transaction t (&m, "remove_layer");
|
||||||
|
li2 = l.insert_layer (db::LayerProperties (2, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ (l.is_valid_layer (li2), true);
|
||||||
|
EXPECT_NE (li, li2);
|
||||||
|
EXPECT_EQ (l.get_properties (li).to_string (), "1/0");
|
||||||
|
EXPECT_EQ (l.get_properties (li2).to_string (), "2/0");
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue