Merge branch 'master' of github.com:KLayout/klayout

This commit is contained in:
Matthias Koefferlein 2024-09-20 23:49:27 +02:00
commit b194d509cc
2 changed files with 48 additions and 1 deletions

View File

@ -251,7 +251,7 @@ LayoutLayers::do_insert_layer (unsigned int index, bool special)
if (index >= layers ()) {
// 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 ()) {
m_free_indices.push_back (layers ());
m_layer_states.push_back (Free);
@ -262,6 +262,14 @@ LayoutLayers::do_insert_layer (unsigned int index, bool special)
tl_assert (m_layer_states [index] == Free);
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;
}
}
}

View File

@ -871,3 +871,42 @@ TEST(11_FindPath)
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");
}
// 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");
}