aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qt/forms/overviewpage.ui332
-rw-r--r--src/qt/overviewpage.cpp2
-rw-r--r--src/sync.cpp35
-rw-r--r--src/sync.h77
-rw-r--r--src/util.cpp1
5 files changed, 239 insertions, 208 deletions
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui
index c7143f3670..6573517b24 100644
--- a/src/qt/forms/overviewpage.ui
+++ b/src/qt/forms/overviewpage.ui
@@ -24,120 +24,141 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
- </property>
- <property name="horizontalSpacing">
- <number>12</number>
- </property>
- <property name="verticalSpacing">
- <number>12</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
- <property name="font">
- <font>
- <pointsize>11</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="text">
- <string>Wallet</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="labelWalletStatus">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="toolTip">
- <string>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</string>
- </property>
- <property name="text">
- <string notr="true">(out of sync)</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Balance:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="labelBalance">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="cursor">
- <cursorShape>IBeamCursor</cursorShape>
- </property>
- <property name="toolTip">
- <string>Your current balance</string>
- </property>
- <property name="text">
- <string notr="true">123.456 BTC</string>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Unconfirmed:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="labelUnconfirmed">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="cursor">
- <cursorShape>IBeamCursor</cursorShape>
- </property>
- <property name="toolTip">
- <string>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</string>
- </property>
- <property name="text">
- <string notr="true">0 BTC</string>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="font">
+ <font>
+ <pointsize>11</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Wallet</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelWalletStatus">
+ <property name="toolTip">
+ <string>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">QLabel { color: red; }</string>
+ </property>
+ <property name="text">
+ <string notr="true">(out of sync)</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Number of transactions:</string>
+ <item>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="labelNumTransactions">
- <property name="toolTip">
- <string>Total number of transactions in wallet</string>
+ <property name="horizontalSpacing">
+ <number>12</number>
</property>
- <property name="text">
- <string notr="true">0</string>
+ <property name="verticalSpacing">
+ <number>12</number>
</property>
- </widget>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Balance:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelBalance">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="toolTip">
+ <string>Your current balance</string>
+ </property>
+ <property name="text">
+ <string notr="true">123.456 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Unconfirmed:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelUnconfirmed">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="toolTip">
+ <string>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</string>
+ </property>
+ <property name="text">
+ <string notr="true">0 BTC</string>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Number of transactions:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="labelNumTransactions">
+ <property name="toolTip">
+ <string>Total number of transactions in wallet</string>
+ </property>
+ <property name="text">
+ <string notr="true">0</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
@@ -167,27 +188,63 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>&lt;b&gt;Recent transactions&lt;/b&gt;</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>&lt;b&gt;Recent transactions&lt;/b&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelTransactionsStatus">
+ <property name="toolTip">
+ <string>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">QLabel { color: red; }</string>
+ </property>
+ <property name="text">
+ <string notr="true">(out of sync)</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="labelTransactionsStatus">
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
+ <item>
+ <widget class="QListView" name="listTransactions">
+ <property name="styleSheet">
+ <string notr="true">QListView { background: transparent; }</string>
</property>
- <property name="toolTip">
- <string>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</string>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
</property>
- <property name="text">
- <string notr="true">(out of sync)</string>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::NoSelection</enum>
</property>
</widget>
</item>
@@ -195,25 +252,6 @@
</widget>
</item>
<item>
- <widget class="QListView" name="listTransactions">
- <property name="styleSheet">
- <string notr="true">QListView { background: transparent; }</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::NoSelection</enum>
- </property>
- </widget>
- </item>
- <item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index e4c742262f..d7bcc6f45e 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -108,9 +108,7 @@ OverviewPage::OverviewPage(QWidget *parent) :
// init "out of sync" warning labels
ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
- ui->labelWalletStatus->setStyleSheet("QLabel { color: red; }");
ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")");
- ui->labelTransactionsStatus->setStyleSheet("QLabel { color: red; }");
// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
diff --git a/src/sync.cpp b/src/sync.cpp
index fd9bcb62bc..d8d86d525e 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -3,8 +3,9 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "sync.h"
+#include "util.h"
-
+#include <boost/foreach.hpp>
#ifdef DEBUG_LOCKORDER
//
@@ -40,7 +41,7 @@ private:
typedef std::vector< std::pair<void*, CLockLocation> > LockStack;
-static boost::interprocess::interprocess_mutex dd_mutex;
+static boost::mutex dd_mutex;
static std::map<std::pair<void*, void*>, LockStack> lockorders;
static boost::thread_specific_ptr<LockStack> lockstack;
@@ -66,7 +67,6 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
{
- bool fOrderOK = true;
if (lockstack.get() == NULL)
lockstack.reset(new LockStack);
@@ -75,20 +75,21 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
(*lockstack).push_back(std::make_pair(c, locklocation));
- if (!fTry) BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack))
- {
- if (i.first == c) break;
-
- std::pair<void*, void*> p1 = std::make_pair(i.first, c);
- if (lockorders.count(p1))
- continue;
- lockorders[p1] = (*lockstack);
-
- std::pair<void*, void*> p2 = std::make_pair(c, i.first);
- if (lockorders.count(p2))
- {
- potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
- break;
+ if (!fTry) {
+ BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) {
+ if (i.first == c) break;
+
+ std::pair<void*, void*> p1 = std::make_pair(i.first, c);
+ if (lockorders.count(p1))
+ continue;
+ lockorders[p1] = (*lockstack);
+
+ std::pair<void*, void*> p2 = std::make_pair(c, i.first);
+ if (lockorders.count(p2))
+ {
+ potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
+ break;
+ }
}
}
dd_mutex.unlock();
diff --git a/src/sync.h b/src/sync.h
index 44d753ac15..1604338fb6 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -5,19 +5,19 @@
#ifndef BITCOIN_SYNC_H
#define BITCOIN_SYNC_H
-#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
-#include <boost/interprocess/sync/scoped_lock.hpp>
-#include <boost/interprocess/sync/interprocess_semaphore.hpp>
-#include <boost/interprocess/sync/lock_options.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/condition_variable.hpp>
/** Wrapped boost mutex: supports recursive locking, but no waiting */
-typedef boost::interprocess::interprocess_recursive_mutex CCriticalSection;
+typedef boost::recursive_mutex CCriticalSection;
/** Wrapped boost mutex: supports waiting but not recursive locking */
-typedef boost::interprocess::interprocess_mutex CWaitableCriticalSection;
+typedef boost::mutex CWaitableCriticalSection;
#ifdef DEBUG_LOCKORDER
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false);
@@ -32,12 +32,12 @@ template<typename Mutex>
class CMutexLock
{
private:
- boost::interprocess::scoped_lock<Mutex> lock;
+ boost::unique_lock<Mutex> lock;
public:
void Enter(const char* pszName, const char* pszFile, int nLine)
{
- if (!lock.owns())
+ if (!lock.owns_lock())
{
EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()));
#ifdef DEBUG_LOCKCONTENTION
@@ -55,7 +55,7 @@ public:
void Leave()
{
- if (lock.owns())
+ if (lock.owns_lock())
{
lock.unlock();
LeaveCritical();
@@ -64,17 +64,17 @@ public:
bool TryEnter(const char* pszName, const char* pszFile, int nLine)
{
- if (!lock.owns())
+ if (!lock.owns_lock())
{
EnterCritical(pszName, pszFile, nLine, (void*)(lock.mutex()), true);
lock.try_lock();
- if (!lock.owns())
+ if (!lock.owns_lock())
LeaveCritical();
}
- return lock.owns();
+ return lock.owns_lock();
}
- CMutexLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) : lock(mutexIn, boost::interprocess::defer_lock)
+ CMutexLock(Mutex& mutexIn, const char* pszName, const char* pszFile, int nLine, bool fTry = false) : lock(mutexIn, boost::defer_lock)
{
if (fTry)
TryEnter(pszName, pszFile, nLine);
@@ -84,16 +84,16 @@ public:
~CMutexLock()
{
- if (lock.owns())
+ if (lock.owns_lock())
LeaveCritical();
}
operator bool()
{
- return lock.owns();
+ return lock.owns_lock();
}
- boost::interprocess::scoped_lock<Mutex> &GetLock()
+ boost::unique_lock<Mutex> &GetLock()
{
return lock;
}
@@ -117,47 +117,40 @@ typedef CMutexLock<CCriticalSection> CCriticalBlock;
LeaveCritical(); \
}
-#ifdef MAC_OSX
-// boost::interprocess::interprocess_semaphore seems to spinlock on OSX; prefer polling instead
class CSemaphore
{
private:
- CCriticalSection cs;
- int val;
+ boost::condition_variable condition;
+ boost::mutex mutex;
+ int value;
public:
- CSemaphore(int init) : val(init) {}
+ CSemaphore(int init) : value(init) {}
void wait() {
- do {
- {
- LOCK(cs);
- if (val>0) {
- val--;
- return;
- }
- }
- Sleep(100);
- } while(1);
+ boost::unique_lock<boost::mutex> lock(mutex);
+ while (value < 1) {
+ condition.wait(lock);
+ }
+ value--;
}
bool try_wait() {
- LOCK(cs);
- if (val>0) {
- val--;
- return true;
- }
- return false;
+ boost::unique_lock<boost::mutex> lock(mutex);
+ if (value < 1)
+ return false;
+ value--;
+ return true;
}
void post() {
- LOCK(cs);
- val++;
+ {
+ boost::unique_lock<boost::mutex> lock(mutex);
+ value++;
+ }
+ condition.notify_one();
}
};
-#else
-typedef boost::interprocess::interprocess_semaphore CSemaphore;
-#endif
/** RAII-style semaphore lock */
class CSemaphoreGrant
diff --git a/src/util.cpp b/src/util.cpp
index 7a163632c8..b0c80f6dfc 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -27,6 +27,7 @@ namespace boost {
#include <boost/foreach.hpp>
#include <openssl/crypto.h>
#include <openssl/rand.h>
+#include <stdarg.h>
#ifdef WIN32
#ifdef _MSC_VER