Skip to content

Commit

Permalink
Fix Sprite Model Crash (#61)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dazappa authored and RobertBColton committed May 9, 2019
1 parent 8fdcf5f commit a149246
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Models/SpriteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a149246

Please sign in to comment.