Commit 71dd7102 authored by Friedemann Kleint's avatar Friedemann Kleint

TestEditor/ModelAdapter: Fix model to pass the model test.

Check for invalid (top level) or valid indexes in the overridden
functions. This prevents crashes due to accessibility traversing
the model.

Task-number: QTCREATORBUG-13142
Change-Id: I22d0831338436479e6ec3b215514bbb9513dffc7
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 89aa06e3
......@@ -117,14 +117,14 @@ ModelAdapter::ModelAdapter(GenericProposalModel *completionModel, QWidget *paren
, m_completionModel(completionModel)
{}
int ModelAdapter::rowCount(const QModelIndex &) const
int ModelAdapter::rowCount(const QModelIndex &index) const
{
return m_completionModel->size();
return index.isValid() ? 0 : m_completionModel->size();
}
QVariant ModelAdapter::data(const QModelIndex &index, int role) const
{
if (index.row() >= m_completionModel->size())
if (!index.isValid() || index.row() >= m_completionModel->size())
return QVariant();
if (role == Qt::DisplayRole)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment