diff options
Diffstat (limited to 'pokescripting/CoinListWrapper.h')
| -rw-r--r-- | pokescripting/CoinListWrapper.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pokescripting/CoinListWrapper.h b/pokescripting/CoinListWrapper.h index 21b902b2..a224545a 100644 --- a/pokescripting/CoinListWrapper.h +++ b/pokescripting/CoinListWrapper.h @@ -32,13 +32,19 @@ class POKESCRIPTING_EXPORT CoinListWrapper : public ObjectWrapper Q_OBJECT public: - CoinListWrapper(const Pokemod::CoinList* coinList, QObject* parent); + static CoinListWrapper* create(const Pokemod::CoinList* coinList, QObject* parent) + { + if (!m_instances.contains(coinList->id())) + m_instances[coinList->id()] = new CoinListWrapper(coinList, parent); + return qobject_cast<CoinListWrapper*>(m_instances[coinList->id()]); + } public slots: QString name() const; - const CoinListObjectWrapper* object(const int index) const; + CoinListObjectWrapper* object(const int index); int objectCount() const; private: + CoinListWrapper(const Pokemod::CoinList* coinList, QObject* parent); CoinListWrapper& operator=(const CoinListWrapper& rhs); const Pokemod::CoinList* m_coinList; @@ -55,9 +61,9 @@ inline QString CoinListWrapper::name() const return m_coinList->name(); } -inline const CoinListObjectWrapper* CoinListWrapper::object(const int index) const +inline CoinListObjectWrapper* CoinListWrapper::object(const int index) { - return new CoinListObjectWrapper(m_coinList->object(index), const_cast<CoinListWrapper*>(this)); + return CoinListObjectWrapper::create(m_coinList->object(index), this); } inline int CoinListWrapper::objectCount() const |
