Skip to content

Commit

Permalink
Fixed #157 (Replace cell with ... from cell tree context menu does no…
Browse files Browse the repository at this point in the history
…t accept decorated cell names)
  • Loading branch information
klayoutmatthias committed Aug 13, 2018
1 parent de729c3 commit 04545e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* Bugfix: https://github.com/klayoutmatthias/klayout/issues/155
Program freezes after replacing nothing by something in
Macro editor
* Bugfix: https://github.com/klayoutmatthias/klayout/issues/157
"Replace cell with ..." rejected cell names with a library
prefix
* Bugfix: 8 bit indexed GIF images can be used for package icons now
* Enhancement: Provide a way to specify the type of a macro
This feature is mainly useful for command line arguments.
Expand Down
16 changes: 14 additions & 2 deletions src/laybasic/laybasic/layDialogs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@ ReplaceCellOptionsDialog::~ReplaceCellOptionsDialog ()
// .. nothing yet ..
}

static std::pair<bool, db::cell_index_type>
find_cell_by_display_name (const db::Layout &layout, const std::string &cn)
{
for (db::Layout::const_iterator c = layout.begin (); c != layout.end (); ++c) {
if (layout.display_name (c->cell_index ()) == cn) {
return std::make_pair (true, c->cell_index ());
}
}

return std::make_pair (false, 0);
}

bool
ReplaceCellOptionsDialog::exec_dialog (const lay::CellView &cv, int &replace_mode, db::cell_index_type &cell_index)
{
Expand All @@ -593,7 +605,7 @@ ReplaceCellOptionsDialog::exec_dialog (const lay::CellView &cv, int &replace_mod
}

std::string cn = tl::to_string (cell_selection_cbx->lineEdit ()->text ());
std::pair<bool, db::cell_index_type> cc = cv->layout ().cell_by_name (cn.c_str ());
std::pair<bool, db::cell_index_type> cc = find_cell_by_display_name (cv->layout (), cn.c_str ());
cell_index = cc.second;

return cc.first;
Expand All @@ -611,7 +623,7 @@ BEGIN_PROTECTED;
lay::CellTreeModel *model = dynamic_cast<lay::CellTreeModel *> (cell_selection_cbx->model ());
if (model) {
std::string cn = tl::to_string (cell_selection_cbx->lineEdit ()->text ());
std::pair<bool, db::cell_index_type> cc = model->layout ()->cell_by_name (cn.c_str ());
std::pair<bool, db::cell_index_type> cc = find_cell_by_display_name (*model->layout (), cn.c_str ());
if (! cc.first) {
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cell name: ")) + cn);
}
Expand Down

0 comments on commit 04545e4

Please sign in to comment.