mirror of https://github.com/KLayout/klayout.git
Fixed issue #1533 (KLayout crashing with two consecutive calls of the same LayoutView::show_layout command)
This commit is contained in:
parent
1e09bee1b6
commit
6e589e2bb3
|
|
@ -277,7 +277,10 @@ static unsigned int show_layout1 (lay::LayoutViewBase *view, db::Layout *layout,
|
|||
{
|
||||
// the layout gets held by the LayoutHandle object
|
||||
layout->keep ();
|
||||
lay::LayoutHandle *handle = new lay::LayoutHandle (layout, std::string ());
|
||||
lay::LayoutHandle *handle = lay::LayoutHandle::find_layout (layout);
|
||||
if (! handle) {
|
||||
handle = new lay::LayoutHandle (layout, std::string ());
|
||||
}
|
||||
return view->add_layout (handle, add_cellview);
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +288,10 @@ static unsigned int show_layout2 (lay::LayoutViewBase *view, db::Layout *layout,
|
|||
{
|
||||
// the layout gets held by the LayoutHandle object
|
||||
layout->keep ();
|
||||
lay::LayoutHandle *handle = new lay::LayoutHandle (layout, std::string ());
|
||||
lay::LayoutHandle *handle = lay::LayoutHandle::find_layout (layout);
|
||||
if (! handle) {
|
||||
handle = new lay::LayoutHandle (layout, std::string ());
|
||||
}
|
||||
handle->set_tech_name (tech);
|
||||
return view->add_layout (handle, add_cellview);
|
||||
}
|
||||
|
|
@ -294,7 +300,10 @@ static unsigned int show_layout3 (lay::LayoutViewBase *view, db::Layout *layout,
|
|||
{
|
||||
// the layout gets held by the LayoutHandle object
|
||||
layout->keep ();
|
||||
lay::LayoutHandle *handle = new lay::LayoutHandle (layout, std::string ());
|
||||
lay::LayoutHandle *handle = lay::LayoutHandle::find_layout (layout);
|
||||
if (! handle) {
|
||||
handle = new lay::LayoutHandle (layout, std::string ());
|
||||
}
|
||||
handle->set_tech_name (tech);
|
||||
return view->add_layout (handle, add_cellview, initialize_layers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,6 +272,17 @@ LayoutHandle::find (const std::string &name)
|
|||
}
|
||||
}
|
||||
|
||||
LayoutHandle *
|
||||
LayoutHandle::find_layout (const db::Layout *layout)
|
||||
{
|
||||
for (auto h = ms_dict.begin (); h != ms_dict.end (); ++h) {
|
||||
if (h->second->mp_layout == layout) {
|
||||
return h->second;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
LayoutHandle::get_names (std::vector <std::string> &names)
|
||||
{
|
||||
|
|
@ -484,6 +495,10 @@ LayoutHandleRef::operator= (const LayoutHandleRef &r)
|
|||
void
|
||||
LayoutHandleRef::set (LayoutHandle *h)
|
||||
{
|
||||
if (mp_handle == h) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mp_handle) {
|
||||
mp_handle->remove_ref ();
|
||||
mp_handle = 0;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,14 @@ public:
|
|||
*/
|
||||
static LayoutHandle *find (const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Finds a handle by layout object
|
||||
*
|
||||
* @param layout The Layout object bound to the handle
|
||||
* @return 0, if there is no layout object with this name. Otherwise a pointer to its handle
|
||||
*/
|
||||
static LayoutHandle *find_layout (const db::Layout *layout);
|
||||
|
||||
/**
|
||||
* @brief Gets the names of all registered layout objects
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -550,6 +550,26 @@ class LAYLayoutView_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# issue-1533
|
||||
def test_8
|
||||
|
||||
if !RBA.constants.member?(:Application)
|
||||
return
|
||||
end
|
||||
|
||||
app = RBA::Application.instance
|
||||
mw = app.main_window
|
||||
mw.close_all
|
||||
mw.create_view
|
||||
|
||||
ly = RBA::Layout::new
|
||||
mw.current_view.show_layout(ly, false)
|
||||
|
||||
# was crashing
|
||||
mw.current_view.show_layout(ly, false)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
Loading…
Reference in New Issue