mirror of https://github.com/KLayout/klayout.git
Add-on making re-registration of PCells a valid feature.
This commit is contained in:
parent
0df6339f4e
commit
072edecb1a
|
|
@ -2526,10 +2526,25 @@ Layout::register_pcell (const std::string &name, pcell_declaration_type *declara
|
|||
// replace any existing PCell declaration with that name.
|
||||
id = pcid->second;
|
||||
if (m_pcells [id]) {
|
||||
delete m_pcells [id];
|
||||
}
|
||||
|
||||
m_pcells [id] = new pcell_header_type (id, name, declaration);
|
||||
std::unique_ptr<pcell_header_type> org_header (m_pcells [id]);
|
||||
std::vector<pcell_variant_type *> variants;
|
||||
for (auto v = org_header->begin (); v != org_header->end (); ++v) {
|
||||
variants.push_back (v->second);
|
||||
}
|
||||
for (auto v = variants.begin (); v != variants.end (); ++v) {
|
||||
(*v)->unregister ();
|
||||
}
|
||||
|
||||
m_pcells [id] = new pcell_header_type (id, name, declaration);
|
||||
|
||||
for (auto v = variants.begin (); v != variants.end (); ++v) {
|
||||
(*v)->reregister ();
|
||||
}
|
||||
|
||||
} else {
|
||||
m_pcells [id] = new pcell_header_type (id, name, declaration);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
|||
|
|
@ -774,6 +774,41 @@ class DBPCell_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
def test_11
|
||||
|
||||
lib = CircleLib1782::new("CircleLib")
|
||||
|
||||
ly = RBA::Layout::new
|
||||
|
||||
top = ly.create_cell("TOP")
|
||||
|
||||
names = []
|
||||
|
||||
c = ly.create_cell("Circle", "CircleLib", { "l" => RBA::LayerInfo::new(1, 0), "r" => 2.0, "n" => 64 })
|
||||
|
||||
# triggered another flavor of #1782
|
||||
lib.reregister_pcell
|
||||
|
||||
c = ly.create_cell("Circle", "CircleLib", { "l" => RBA::LayerInfo::new(1, 0), "r" => 2.0, "n" => 64 })
|
||||
top.insert(RBA::DCellInstArray::new(c, RBA::DTrans::new()))
|
||||
|
||||
tmp = File::join($ut_testtmp, "tmp.gds")
|
||||
ly.write(tmp)
|
||||
|
||||
# this should not throw an internal error
|
||||
ly._destroy
|
||||
|
||||
# we should be able to read the Layout back
|
||||
ly = RBA::Layout::new
|
||||
ly.read(tmp)
|
||||
assert_equal(ly.top_cell.name, "TOP")
|
||||
assert_equal(ly.cells, 2)
|
||||
ly._destroy
|
||||
|
||||
lib._destroy
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
Loading…
Reference in New Issue