Fixed segfault in datafilesmodel because of invalid modelindex row

pull/37/head
Pieter van der Kloet 12 years ago
parent 6920958e16
commit 433773e0ea

@ -60,10 +60,10 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
// if (index.row() < 0 || index.row() >= mPlugins.size())
// return QVariant();
EsmFile *file = item(index.row());
EsmFile *file = mFiles.at(index.row());
if (!file)
return QVariant();
const int column = index.column();
@ -146,7 +146,10 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const
if (!index.isValid())
return Qt::NoItemFlags;
EsmFile *file = mFiles.at(index.row());
EsmFile *file = item(index.row());
if (!file)
return Qt::NoItemFlags;
if (mAvailableFiles.contains(file->fileName())) {
if (index.column() == 0) {
@ -384,7 +387,7 @@ EsmFile* DataFilesModel::findItem(const QString &name)
return 0;
}
EsmFile* DataFilesModel::item(int row)
EsmFile* DataFilesModel::item(int row) const
{
if (row >= 0 && row < mFiles.count())
return mFiles.at(row);

@ -47,7 +47,7 @@ public:
QModelIndex indexFromItem(EsmFile *item) const;
EsmFile* findItem(const QString &name);
EsmFile* item(int row);
EsmFile* item(int row) const;
signals:
void checkedItemsChanged(const QStringList checkedItems, const QStringList unCheckedItems);

Loading…
Cancel
Save