diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-04-23 17:05:36 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-04-23 17:06:28 +0200 |
| commit | 89bbd54fbfbb1b21257d436731868455821a101e (patch) | |
| tree | a394f051221cb79d684d5643855597187fabc210 /src/qt/transactiontablemodel.cpp | |
| parent | Merge pull request #4055 (diff) | |
| parent | Add missing AssertLockHeld in ConnectBlock (diff) | |
| download | discoin-89bbd54fbfbb1b21257d436731868455821a101e.tar.xz discoin-89bbd54fbfbb1b21257d436731868455821a101e.zip | |
Merge pull request #4085
b39a07d Add missing AssertLockHeld in ConnectBlock (Wladimir J. van der Laan)
41106a5 qt: get required locks upfront in polling functions (Wladimir J. van der Laan)
ed67100 Add required locks in tests (Wladimir J. van der Laan)
Diffstat (limited to 'src/qt/transactiontablemodel.cpp')
| -rw-r--r-- | src/qt/transactiontablemodel.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index aaecf88c2..df412650d 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -24,7 +24,6 @@ #include <QDebug> #include <QIcon> #include <QList> -#include <QTimer> // Amount column is right-aligned it contains numbers static int column_alignments[] = { @@ -187,17 +186,25 @@ public: { TransactionRecord *rec = &cachedWallet[idx]; + // Get required locks upfront. This avoids the GUI from getting + // stuck if the core is holding the locks for a longer time - for + // example, during a wallet rescan. + // // If a status update is needed (blocks came in since last check), // update the status of this transaction from the wallet. Otherwise, // simply re-use the cached status. - LOCK2(cs_main, wallet->cs_wallet); - if(rec->statusUpdateNeeded()) + TRY_LOCK(cs_main, lockMain); + if(lockMain) { - std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash); - - if(mi != wallet->mapWallet.end()) + TRY_LOCK(wallet->cs_wallet, lockWallet); + if(lockWallet && rec->statusUpdateNeeded()) { - rec->updateStatus(mi->second); + std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash); + + if(mi != wallet->mapWallet.end()) + { + rec->updateStatus(mi->second); + } } } return rec; |