forked from osmocom/wireshark
Qt: fix weird tree expander that results in a crash
According to the Qt documentation, rowCount and columnCount must return 0 when a valid parent index is passed to a table model. Otherwise deep recursion would occur resulting in a stack overflow in Qt4. Change-Id: I60bb15384470861013591e149c0f285ea1bdf9a7 Fixes: v2.3.0rc0-1002-g1cd2255 ("Qt: convert UatDialog to model/view pattern, improve UX") Reviewed-on: https://code.wireshark.org/review/18354 Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com> Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
67bfdf2871
commit
991e0747a3
|
@ -47,7 +47,6 @@ Qt::ItemFlags UatModel::flags(const QModelIndex &index) const
|
|||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
// Note: Qt::ItemNeverHasChildren is not just for optimization, it avoids crashes too with QTreeView...
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
flags |= Qt::ItemIsEditable;
|
||||
return flags;
|
||||
|
@ -109,13 +108,23 @@ QVariant UatModel::headerData(int section, Qt::Orientation orientation, int role
|
|||
return uat_->fields[section].title;
|
||||
}
|
||||
|
||||
int UatModel::rowCount(const QModelIndex &/*parent*/) const
|
||||
int UatModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
// there are no children
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return uat_->raw_data->len;
|
||||
}
|
||||
|
||||
int UatModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
int UatModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
// there are no children
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return uat_->ncols;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue