mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
qt: Fix regression in TransactionTableModel
Since #17993 a crash is possible on exit. Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
parent
dbd7a91fdf
commit
d906aaa117
4 changed files with 12 additions and 3 deletions
|
@ -234,6 +234,7 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons
|
||||||
|
|
||||||
bool TransactionRecord::statusUpdateNeeded(const uint256& block_hash) const
|
bool TransactionRecord::statusUpdateNeeded(const uint256& block_hash) const
|
||||||
{
|
{
|
||||||
|
assert(!block_hash.IsNull());
|
||||||
return status.m_cur_block_hash != block_hash || status.needsUpdate;
|
return status.m_cur_block_hash != block_hash || status.needsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ public:
|
||||||
interfaces::WalletTxStatus wtx;
|
interfaces::WalletTxStatus wtx;
|
||||||
int numBlocks;
|
int numBlocks;
|
||||||
int64_t block_time;
|
int64_t block_time;
|
||||||
if (rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
|
if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
|
||||||
rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
|
rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
|
||||||
}
|
}
|
||||||
return rec;
|
return rec;
|
||||||
|
@ -664,7 +664,7 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
|
||||||
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->clientModel().getBestBlockHash(), row);
|
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->getLastBlockProcessed(), row);
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
return createIndex(row, column, data);
|
return createIndex(row, column, data);
|
||||||
|
|
|
@ -87,7 +87,7 @@ void WalletModel::pollBalanceChanged()
|
||||||
{
|
{
|
||||||
// Avoid recomputing wallet balances unless a TransactionChanged or
|
// Avoid recomputing wallet balances unless a TransactionChanged or
|
||||||
// BlockTip notification was received.
|
// BlockTip notification was received.
|
||||||
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == m_client_model->getBestBlockHash()) return;
|
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == getLastBlockProcessed()) return;
|
||||||
|
|
||||||
// Try to get balances and return early if locks can't be acquired. This
|
// Try to get balances and return early if locks can't be acquired. This
|
||||||
// avoids the GUI from getting stuck on periodical polls if the core is
|
// avoids the GUI from getting stuck on periodical polls if the core is
|
||||||
|
@ -588,3 +588,8 @@ void WalletModel::refresh(bool pk_hash_only)
|
||||||
{
|
{
|
||||||
addressTableModel = new AddressTableModel(this, pk_hash_only);
|
addressTableModel = new AddressTableModel(this, pk_hash_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 WalletModel::getLastBlockProcessed() const
|
||||||
|
{
|
||||||
|
return m_client_model ? m_client_model->getBestBlockHash() : uint256{};
|
||||||
|
}
|
||||||
|
|
|
@ -155,6 +155,9 @@ public:
|
||||||
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
|
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
|
||||||
|
|
||||||
void refresh(bool pk_hash_only = false);
|
void refresh(bool pk_hash_only = false);
|
||||||
|
|
||||||
|
uint256 getLastBlockProcessed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<interfaces::Wallet> m_wallet;
|
std::unique_ptr<interfaces::Wallet> m_wallet;
|
||||||
std::unique_ptr<interfaces::Handler> m_handler_unload;
|
std::unique_ptr<interfaces::Handler> m_handler_unload;
|
||||||
|
|
Loading…
Reference in a new issue