diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/laybasic/laybasic/layNetlistBrowserModel.cc index 048e683a1..2ce92ea97 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserModel.cc @@ -206,6 +206,8 @@ static inline bool always (bool) return true; } +static void *no_id = reinterpret_cast (-1); + NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutToNetlist *l2ndb, NetColorizer *colorizer) : QAbstractItemModel (parent), mp_l2ndb (l2ndb), mp_lvsdb (0), mp_colorizer (colorizer) { @@ -830,7 +832,7 @@ std::string devices_string (const std::pairparent_of (nets); - void *id = 0; + void *id = no_id; // NOTE: the nets may not be a valid net pair. In this case, circuits is (0, 0) and // no link is generated if (circuits.first || circuits.second) { @@ -882,7 +884,7 @@ NetlistBrowserModel::make_link_to (const std::pairparent_of (devices); - void *id = 0; + void *id = no_id; // NOTE: the devices may not be a valid device pair. In this case, circuits is (0, 0) and // no link is generated if (circuits.first || circuits.second) { @@ -942,7 +944,7 @@ NetlistBrowserModel::make_link_to (const std::pairparent_of (subcircuits); - void *id = 0; + void *id = no_id; // NOTE: the subcircuits may not be a valid subcircuit pair. In this case, circuits is (0, 0) and // no link is generated if (circuits.first || circuits.second) { @@ -2012,7 +2014,7 @@ NetlistBrowserModel::headerData (int section, Qt::Orientation /*orientation*/, i QModelIndex NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) const { - void *new_id = 0; + void *new_id = no_id; if (! parent.isValid ()) { @@ -2092,7 +2094,11 @@ NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) cons } - return createIndex (row, column, new_id); + if (new_id != no_id) { + return createIndex (row, column, new_id); + } else { + return QModelIndex (); + } } void diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index af6bc6494..203245fb3 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -742,7 +742,7 @@ NetlistBrowserPage::set_db (db::LayoutToNetlist *l2ndb) clear_markers (); highlight (std::vector (), std::vector (), std::vector (), std::vector ()); - m_cell_context_cache = db::ContextCache (mp_database->internal_layout ()); + m_cell_context_cache = db::ContextCache (mp_database.get () ? mp_database->internal_layout () : 0); setup_trees (); }