Skip to content

Commit 0c7708a

Browse files
UI: Add locks (thanks @dexX7)
1 parent 0df4c94 commit 0c7708a

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/omnicore/omnicore.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,13 @@ using std::vector;
9595

9696
using namespace mastercore;
9797

98-
99-
// comment out MY_HACK & others here - used for Unit Testing only !
100-
// #define MY_HACK
98+
CCriticalSection cs_tally;
10199

102100
static string exodus_address = "1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P";
103101
static const string exodus_testnet = "mpexoDuSkGGqvqrkrjiFng38QPkJQVFyqv";
104102
static const string getmoney_testnet = "moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP";
105103

106-
static int nWaterlineBlock = 0; //
104+
static int nWaterlineBlock = 0;
107105

108106
//! Available balances of wallet properties
109107
std::map<uint32_t, int64_t> global_balance_money;
@@ -280,8 +278,6 @@ std::string FormatMP(unsigned int property, int64_t n, bool fSign)
280278

281279
string const CMPSPInfo::watermarkKey("watermark");
282280

283-
CCriticalSection cs_tally;
284-
285281
OfferMap mastercore::my_offers;
286282
AcceptMap mastercore::my_accepts;
287283

src/qt/balancesdialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ void BalancesDialog::UpdatePropSelector()
133133
// don't waste time updating if there are no new properties
134134
if ((uint32_t)ui->propSelectorWidget->count() > global_wallet_property_list.size()) return;
135135

136+
LOCK(cs_tally);
137+
136138
// a new property has been added to the wallet, update the property selector
137139
QString spId = ui->propSelectorWidget->itemData(ui->propSelectorWidget->currentIndex()).toString();
138140
ui->propSelectorWidget->clear();
@@ -171,6 +173,8 @@ void BalancesDialog::AddRow(const std::string& label, const std::string& address
171173
void BalancesDialog::PopulateBalances(unsigned int propertyId)
172174
{
173175
ui->balancesTable->setRowCount(0); // fresh slate (note this will automatically cleanup all existing QWidgetItems in the table)
176+
177+
LOCK(cs_tally);
174178
//are we summary?
175179
if(propertyId==2147483646) {
176180
ui->balancesTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Property ID"));
@@ -188,7 +192,6 @@ void BalancesDialog::PopulateBalances(unsigned int propertyId)
188192
} else {
189193
ui->balancesTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Label"));
190194
ui->balancesTable->setHorizontalHeaderItem(1, new QTableWidgetItem("Address"));
191-
LOCK(cs_tally);
192195
bool propertyIsDivisible = isPropertyDivisible(propertyId); // only fetch the SP once, not for every address
193196

194197
// iterate mp_tally_map looking for addresses that hold a balance in propertyId

src/qt/overviewpage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ void OverviewPage::updateOmni()
288288
// alert status when we're notified of an Omni state change
289289
updateAlerts();
290290

291+
LOCK(cs_tally);
292+
291293
// always show MSC
292294
UpdatePropertyBalance(1,global_balance_money[1],global_balance_reserved[1]);
293295
// loop properties and update overview

src/qt/sendmpdialog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ void SendMPDialog::updatePropSelector()
9494
uint32_t nextPropIdTestEco = GetNextPropertyId(false); // property ID rather than a fixed value like 100000 (optimization)
9595
QString spId = ui->propertyComboBox->itemData(ui->propertyComboBox->currentIndex()).toString();
9696
ui->propertyComboBox->clear();
97+
98+
LOCK(cs_tally);
99+
97100
for (unsigned int propertyId = 1; propertyId < nextPropIdMainEco; propertyId++) {
98101
if ((global_balance_money[propertyId] > 0) || (global_balance_reserved[propertyId] > 0)) {
99102
std::string spName = getPropertyName(propertyId);

0 commit comments

Comments
 (0)