forked from qt-creator/qt-creator
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 <eike.ziller@qt.io> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user