forked from Public/monero-gui
Transaction history is not crashing and refreshing properly
This commit is contained in:
@@ -7,54 +7,53 @@
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(int index)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(index);
|
||||
if (!impl) {
|
||||
|
||||
if (index < 0 || index >= m_tinfo.size()) {
|
||||
qCritical("%s: no transaction info for index %d", __FUNCTION__, index);
|
||||
qCritical("%s: there's %d transactions in backend", __FUNCTION__, m_pimpl->count());
|
||||
return nullptr;
|
||||
}
|
||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
||||
return result;
|
||||
return m_tinfo.at(index);
|
||||
}
|
||||
|
||||
TransactionInfo *TransactionHistory::transaction(const QString &id)
|
||||
{
|
||||
// box up Bitmonero::TransactionInfo
|
||||
Bitmonero::TransactionInfo * impl = m_pimpl->transaction(id.toStdString());
|
||||
TransactionInfo * result = new TransactionInfo(impl, this);
|
||||
return result;
|
||||
}
|
||||
//// XXX: not sure if this method really needed;
|
||||
//TransactionInfo *TransactionHistory::transaction(const QString &id)
|
||||
//{
|
||||
// return nullptr;
|
||||
//}
|
||||
|
||||
QList<TransactionInfo *> TransactionHistory::getAll() const
|
||||
{
|
||||
// XXX this invalidates previously saved history that might be used by model
|
||||
emit refreshStarted();
|
||||
qDeleteAll(m_tinfo);
|
||||
m_tinfo.clear();
|
||||
TransactionHistory * parent = const_cast<TransactionHistory*>(this);
|
||||
for (const auto i : m_pimpl->getAll()) {
|
||||
TransactionInfo * ti = new TransactionInfo(i, parent);
|
||||
qDebug() << ti->hash();
|
||||
m_tinfo.append(ti);
|
||||
}
|
||||
emit refreshFinished();
|
||||
return m_tinfo;
|
||||
}
|
||||
|
||||
void TransactionHistory::refresh()
|
||||
{
|
||||
// XXX this invalidates previously saved history that might be used by clients
|
||||
|
||||
emit refreshStarted();
|
||||
// rebuilding transaction list in wallet_api;
|
||||
m_pimpl->refresh();
|
||||
emit refreshFinished();
|
||||
// copying list here and keep track on every item to avoid memleaks
|
||||
getAll();
|
||||
}
|
||||
|
||||
quint64 TransactionHistory::count() const
|
||||
{
|
||||
return m_pimpl->count();
|
||||
return m_tinfo.count();
|
||||
}
|
||||
|
||||
|
||||
TransactionHistory::TransactionHistory(Bitmonero::TransactionHistory *pimpl, QObject *parent)
|
||||
: QObject(parent), m_pimpl(pimpl)
|
||||
{
|
||||
|
||||
// this->refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user