From 57654f11288180e5663f99a1da1cd7a4cf06ad0f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 9 Jun 2008 03:00:41 +0000 Subject: [FIX] Some crashes in the Models that grab names from other objects git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@203 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/models/CoinListObjectModel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pokemodr/models/CoinListObjectModel.cpp') diff --git a/pokemodr/models/CoinListObjectModel.cpp b/pokemodr/models/CoinListObjectModel.cpp index 8e86767c..929dcb69 100644 --- a/pokemodr/models/CoinListObjectModel.cpp +++ b/pokemodr/models/CoinListObjectModel.cpp @@ -53,15 +53,15 @@ QVariant Pokemodr::CoinListObjectModel::data(int role) const Pokemod::CoinListObject* object = static_cast(m_object); if (object->type() == Pokemod::CoinListObject::Item) { - const Pokemod::Item* item = static_cast(m_object->pokemod())->itemById(object->object()); - if (item) - return item->name(); + const int index = static_cast(m_object->pokemod())->itemIndex(object->object()); + if (index != INT_MAX) + return static_cast(m_object->pokemod())->item(index)->name(); } else if (object->type() == Pokemod::CoinListObject::Species) { - const Pokemod::Species* species = static_cast(m_object->pokemod())->speciesById(object->object()); - if (species) - return species->name(); + const int index = static_cast(m_object->pokemod())->speciesIndex(object->object()); + if (index != INT_MAX) + return static_cast(m_object->pokemod())->species(index)->name(); } return ""; } -- cgit