From a149246b4ce1850233dda0fb348717903894c52d Mon Sep 17 00:00:00 2001 From: Matthew Shaffer Date: Thu, 9 May 2019 08:48:07 -0400 Subject: [PATCH] Fix Sprite Model Crash (#61) Check the index validity in the data method of the sprite model. This stops the crash when creating a new sprite but does not fix the underlying problem yet. --- Models/SpriteModel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Models/SpriteModel.cpp b/Models/SpriteModel.cpp index 67210e7d0..ea8a373ca 100644 --- a/Models/SpriteModel.cpp +++ b/Models/SpriteModel.cpp @@ -21,6 +21,7 @@ QSize SpriteModel::GetIconSize() { return data(index(0), Qt::SizeHintRole).toSiz int SpriteModel::rowCount(const QModelIndex& /*parent*/) const { return protobuf->size(); } QVariant SpriteModel::data(const QModelIndex& index, int role) const { + if (!index.isValid()) return QVariant(); if (role == Qt::DecorationRole) return QIcon(QString::fromStdString(protobuf->Get(index.row()))); else if (role == Qt::BackgroundColorRole) {