WIP: fixed a display issue and a segfault in the netlist browser.

This commit is contained in:
Matthias Koefferlein 2019-06-28 11:45:58 +02:00
parent 80d86cc425
commit a8f8ca0d7d
2 changed files with 13 additions and 7 deletions

View File

@ -206,6 +206,8 @@ static inline bool always (bool)
return true; return true;
} }
static void *no_id = reinterpret_cast<void *> (-1);
NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutToNetlist *l2ndb, NetColorizer *colorizer) NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutToNetlist *l2ndb, NetColorizer *colorizer)
: QAbstractItemModel (parent), mp_l2ndb (l2ndb), mp_lvsdb (0), mp_colorizer (colorizer) : QAbstractItemModel (parent), mp_l2ndb (l2ndb), mp_lvsdb (0), mp_colorizer (colorizer)
{ {
@ -830,7 +832,7 @@ std::string devices_string (const std::pair<const db::Device *, const db::Device
static QString build_url (void *id, const std::string &tag, const std::string &title) static QString build_url (void *id, const std::string &tag, const std::string &title)
{ {
if (id == 0) { if (id == no_id) {
// no link // no link
return tl::to_qstring (tl::escaped_to_html (title)); return tl::to_qstring (tl::escaped_to_html (title));
} }
@ -856,7 +858,7 @@ NetlistBrowserModel::make_link_to (const std::pair<const db::Net *, const db::Ne
} else { } else {
IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_of (nets); IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_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 // NOTE: the nets may not be a valid net pair. In this case, circuits is (0, 0) and
// no link is generated // no link is generated
if (circuits.first || circuits.second) { if (circuits.first || circuits.second) {
@ -882,7 +884,7 @@ NetlistBrowserModel::make_link_to (const std::pair<const db::Device *, const db:
} else { } else {
IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_of (devices); IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_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 // NOTE: the devices may not be a valid device pair. In this case, circuits is (0, 0) and
// no link is generated // no link is generated
if (circuits.first || circuits.second) { if (circuits.first || circuits.second) {
@ -942,7 +944,7 @@ NetlistBrowserModel::make_link_to (const std::pair<const db::SubCircuit *, const
} else { } else {
IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_of (subcircuits); IndexedNetlistModel::circuit_pair circuits = mp_indexer->parent_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 // NOTE: the subcircuits may not be a valid subcircuit pair. In this case, circuits is (0, 0) and
// no link is generated // no link is generated
if (circuits.first || circuits.second) { if (circuits.first || circuits.second) {
@ -2012,7 +2014,7 @@ NetlistBrowserModel::headerData (int section, Qt::Orientation /*orientation*/, i
QModelIndex QModelIndex
NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) const NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) const
{ {
void *new_id = 0; void *new_id = no_id;
if (! parent.isValid ()) { 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 void

View File

@ -742,7 +742,7 @@ NetlistBrowserPage::set_db (db::LayoutToNetlist *l2ndb)
clear_markers (); clear_markers ();
highlight (std::vector<const db::Net *> (), std::vector<const db::Device *> (), std::vector<const db::SubCircuit *> (), std::vector<const db::Circuit *> ()); highlight (std::vector<const db::Net *> (), std::vector<const db::Device *> (), std::vector<const db::SubCircuit *> (), std::vector<const db::Circuit *> ());
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 (); setup_trees ();
} }