Browse Source

Workaround for bug on wxWidgets 2.9.0 Ubuntu 9.10 64-bit where first character of the hidden columns were displayed so status column had three numbers overprinted. Fixed by adding a leading space to the hidden columns. 64-bit compile with wxWidgets 2.9.0 seems to be fully working normally now.

0.8
s_nakamoto 15 years ago
parent
commit
7271c7ff35
  1. 8
      bignum.h
  2. 11
      main.cpp
  3. 2
      net.cpp
  4. 2
      rpc.cpp
  5. 40
      ui.cpp
  6. 14
      uint256.h

8
bignum.h

@ -64,12 +64,6 @@ public:
} }
} }
explicit CBigNum(const std::string& str)
{
BN_init(this);
SetHex(str);
}
CBigNum& operator=(const CBigNum& b) CBigNum& operator=(const CBigNum& b)
{ {
if (!BN_copy(this, &b)) if (!BN_copy(this, &b))
@ -407,6 +401,7 @@ public:
CBigNum& operator>>=(unsigned int shift) CBigNum& operator>>=(unsigned int shift)
{ {
// Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number
if (!BN_rshift(this, this, shift)) if (!BN_rshift(this, this, shift))
throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
return *this; return *this;
@ -516,6 +511,7 @@ inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
{ {
CBigNum r; CBigNum r;
// Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number
if (!BN_rshift(&r, &a, shift)) if (!BN_rshift(&r, &a, shift))
throw bignum_error("CBigNum:operator>> : BN_rshift failed"); throw bignum_error("CBigNum:operator>> : BN_rshift failed");
return r; return r;

11
main.cpp

@ -1570,7 +1570,9 @@ bool LoadBlockIndex(bool fAllowNew)
txNew.vout.resize(1); txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 50 * COIN; txNew.vout[0].nValue = 50 * COIN;
txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG; CBigNum bnPubKey;
bnPubKey.SetHex("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704");
txNew.vout[0].scriptPubKey = CScript() << bnPubKey << OP_CHECKSIG;
CBlock block; CBlock block;
block.vtx.push_back(txNew); block.vtx.push_back(txNew);
block.hashPrevBlock = 0; block.hashPrevBlock = 0;
@ -3022,12 +3024,9 @@ string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtx
return "You don't have enough money"; return "You don't have enough money";
// Parse bitcoin address // Parse bitcoin address
uint160 hash160; CScript scriptPubKey;
if (!AddressToHash160(strAddress, hash160)) if (!scriptPubKey.SetBitcoinAddress(strAddress))
return "Invalid bitcoin address"; return "Invalid bitcoin address";
// Send to bitcoin address
CScript scriptPubKey;
scriptPubKey.SetBitcoinAddress(hash160);
return SendMoney(scriptPubKey, nValue, wtxNew); return SendMoney(scriptPubKey, nValue, wtxNew);
} }

2
net.cpp

@ -1032,7 +1032,7 @@ void ThreadMessageHandler2(void* parg)
{ {
printf("ThreadMessageHandler started\n"); printf("ThreadMessageHandler started\n");
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
loop while (!fShutdown)
{ {
// Poll the connected nodes for messages // Poll the connected nodes for messages
vector<CNode*> vNodesCopy; vector<CNode*> vNodesCopy;

2
rpc.cpp

@ -503,7 +503,7 @@ Value CallRPC(const string& strMethod, const Array& params)
// Connect to localhost // Connect to localhost
tcp::iostream stream("127.0.0.1", "8332"); tcp::iostream stream("127.0.0.1", "8332");
if (stream.fail()) if (stream.fail())
throw runtime_error("unable to connect to server"); throw runtime_error("couldn't connect to server");
// Send request // Send request
string strRequest = JSONRPCRequest(strMethod, params, 1); string strRequest = JSONRPCRequest(strMethod, params, 1);

40
ui.cpp

@ -328,7 +328,7 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
m_toolBar->Realize(); m_toolBar->Realize();
// resize to fit ubuntu's huge default font // resize to fit ubuntu's huge default font
dResize = 1.20; dResize = 1.20;
SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight()); SetSize((dResize + 0.02) * GetSize().GetWidth(), 1.09 * GetSize().GetHeight());
#endif #endif
m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " "); m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");
m_listCtrl->SetFocus(); m_listCtrl->SetFocus();
@ -346,24 +346,6 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, dResize * 79); m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, dResize * 79);
m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, dResize * 79); m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, dResize * 79);
//m_listCtrlProductsSent->InsertColumn(0, "Category", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlProductsSent->InsertColumn(1, "Title", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlProductsSent->InsertColumn(2, "Description", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlProductsSent->InsertColumn(3, "Price", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlProductsSent->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersSent->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersSent->InsertColumn(1, "Price", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersSent->InsertColumn(2, "", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersSent->InsertColumn(3, "", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersSent->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersReceived->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersReceived->InsertColumn(1, "Price", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersReceived->InsertColumn(2, "Payment Status", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersReceived->InsertColumn(3, "", wxLIST_FORMAT_LEFT, 100);
//m_listCtrlOrdersReceived->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);
// Init status bar // Init status bar
int pnWidths[3] = { -100, 88, 290 }; int pnWidths[3] = { -100, 88, 290 };
#ifndef __WXMSW__ #ifndef __WXMSW__
@ -503,33 +485,34 @@ int CMainFrame::GetSortIndex(const string& strSort)
void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6) void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6)
{ {
string str0 = strSort; strSort = " " + strSort; // leading space to workaround wx2.9.0 ubuntu 9.10 bug
long nData = *(long*)&hashKey; long nData = *(long*)&hashKey; // where first char of hidden column is displayed
// Find item // Find item
if (!fNew && nIndex == -1) if (!fNew && nIndex == -1)
{ {
string strHash = " " + hashKey.ToString();
while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1) while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)
if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString()) if (GetItemText(m_listCtrl, nIndex, 1) == strHash)
break; break;
} }
// fNew is for blind insert, only use if you're sure it's new // fNew is for blind insert, only use if you're sure it's new
if (fNew || nIndex == -1) if (fNew || nIndex == -1)
{ {
nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0); nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);
} }
else else
{ {
// If sort key changed, must delete and reinsert to make it relocate // If sort key changed, must delete and reinsert to make it relocate
if (GetItemText(m_listCtrl, nIndex, 0) != str0) if (GetItemText(m_listCtrl, nIndex, 0) != strSort)
{ {
m_listCtrl->DeleteItem(nIndex); m_listCtrl->DeleteItem(nIndex);
nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0); nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);
} }
} }
m_listCtrl->SetItem(nIndex, 1, hashKey.ToString()); m_listCtrl->SetItem(nIndex, 1, " " + hashKey.ToString());
m_listCtrl->SetItem(nIndex, 2, str2); m_listCtrl->SetItem(nIndex, 2, str2);
m_listCtrl->SetItem(nIndex, 3, str3); m_listCtrl->SetItem(nIndex, 3, str3);
m_listCtrl->SetItem(nIndex, 4, str4); m_listCtrl->SetItem(nIndex, 4, str4);
@ -544,8 +527,9 @@ bool CMainFrame::DeleteLine(uint256 hashKey)
// Find item // Find item
int nIndex = -1; int nIndex = -1;
string strHash = " " + hashKey.ToString();
while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1) while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)
if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString()) if (GetItemText(m_listCtrl, nIndex, 1) == strHash)
break; break;
if (nIndex != -1) if (nIndex != -1)
@ -1916,7 +1900,7 @@ CSendingDialog::CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 n
fUIDone = false; fUIDone = false;
fWorkDone = false; fWorkDone = false;
#ifndef __WXMSW__ #ifndef __WXMSW__
SetSize(1.2 * GetSize().GetWidth(), 1.05 * GetSize().GetHeight()); SetSize(1.2 * GetSize().GetWidth(), 1.08 * GetSize().GetHeight());
#endif #endif
SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str())); SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));

14
uint256.h

@ -299,19 +299,18 @@ public:
return string(psz, psz + sizeof(pn)*2); return string(psz, psz + sizeof(pn)*2);
} }
void SetHex(const std::string& str) void SetHex(const char* psz)
{ {
for (int i = 0; i < WIDTH; i++) for (int i = 0; i < WIDTH; i++)
pn[i] = 0; pn[i] = 0;
// skip 0x // skip leading spaces
const char* psz = str.c_str();
while (isspace(*psz)) while (isspace(*psz))
psz++; psz++;
// skip 0x
if (psz[0] == '0' && tolower(psz[1]) == 'x') if (psz[0] == '0' && tolower(psz[1]) == 'x')
psz += 2; psz += 2;
while (isspace(*psz))
psz++;
// hex string to uint // hex string to uint
static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 }; static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
@ -332,6 +331,11 @@ public:
} }
} }
void SetHex(const std::string& str)
{
SetHex(str.c_str());
}
std::string ToString() const std::string ToString() const
{ {
return (GetHex()); return (GetHex());

Loading…
Cancel
Save