From: <arn...@us...> - 2006-03-08 22:45:29
|
Revision: 587 Author: arnetheduck Date: 2006-03-08 14:45:13 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/dcplusplus/?rev=587&view=rev Log Message: ----------- mem bug fixed, a few other minor things Modified Paths: -------------- dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/windows/ExListViewCtrl.h dcplusplus/trunk/windows/PublicHubsFrm.cpp Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-03-08 22:45:13 UTC (rev 587) @@ -180,6 +180,7 @@ string::size_type pos = 0; AutoArray<u_int8_t> buffer (BufSize); size_t in; + l = line; // decompress all input data and store in l. while (left) { in = BufSize; @@ -200,7 +201,7 @@ l.erase (0, pos + 1 /* seperator char */); } // store remainder - line += l; + line = l; break; } Modified: dcplusplus/trunk/client/QueueManager.cpp =================================================================== --- dcplusplus/trunk/client/QueueManager.cpp 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/client/QueueManager.cpp 2006-03-08 22:45:13 UTC (rev 587) @@ -1048,13 +1048,13 @@ void QueueManager::removeSource(User::Ptr& aUser, int reason) throw() { string x; - StringList removeList; + string removeRunning; { Lock l(cs); QueueItem* qi = NULL; while( (qi = userQueue.getNext(aUser, QueueItem::PAUSED)) != NULL) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { - removeList.push_back(qi->getTarget()); + remove(qi->getTarget()); } else { userQueue.remove(qi, aUser); qi->removeSource(aUser, reason); @@ -1066,7 +1066,7 @@ qi = userQueue.getRunning(aUser); if(qi != NULL) { if(qi->isSet(QueueItem::FLAG_USER_LIST)) { - removeList.push_back(qi->getTarget()); + removeRunning = qi->getTarget(); } else { userQueue.setWaiting(qi); userQueue.remove(qi, aUser); @@ -1081,8 +1081,8 @@ if(!x.empty()) { DownloadManager::getInstance()->abortDownload(x); } - for(StringIter i = removeList.begin(); i != removeList.end(); ++i) { - remove(*i); + if(!removeRunning.empty()) { + remove(removeRunning); } } Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/client/Util.cpp 2006-03-08 22:45:13 UTC (rev 587) @@ -393,6 +393,24 @@ return buf; } +double Util::toBytes(TCHAR* aSize) { + double bytes = _tstof(aSize); + + if (_tcsstr(aSize, CTSTRING(PIB))) { + return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(TiB))) { + return bytes * 1024.0 * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(GiB))) { + return bytes * 1024.0 * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(MiB))) { + return bytes * 1024.0 * 1024.0; + } else if (_tcsstr(aSize, CTSTRING(KiB))) { + return bytes * 1024.0; + } else { + return bytes; + } +} + string Util::formatExactSize(int64_t aBytes) { #ifdef _WIN32 TCHAR buf[64]; Modified: dcplusplus/trunk/client/Util.h =================================================================== --- dcplusplus/trunk/client/Util.h 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/client/Util.h 2006-03-08 22:45:13 UTC (rev 587) @@ -272,6 +272,8 @@ static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); } + + static double toBytes(TCHAR* aSize); static string toDOS(const string& tmp); Modified: dcplusplus/trunk/windows/ExListViewCtrl.h =================================================================== --- dcplusplus/trunk/windows/ExListViewCtrl.h 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/windows/ExListViewCtrl.h 2006-03-08 22:45:13 UTC (rev 587) @@ -40,7 +40,8 @@ SORT_STRING, SORT_STRING_NOCASE, SORT_INT, - SORT_FLOAT + SORT_FLOAT, + SORT_BYTES }; typedef ListViewArrows<ExListViewCtrl> arrowBase; @@ -143,7 +144,11 @@ p->GetItemText(na, p->sortColumn, buf, 128); p->GetItemText(nb, p->sortColumn, buf2, 128); result = compare(_tstof(buf), _tstof(buf2)); - } + } else if(result == SORT_BYTES) { + p->GetItemText(na, p->sortColumn, buf, 128); + p->GetItemText(nb, p->sortColumn, buf2, 128); + result = compare(Util::toBytes(buf), Util::toBytes(buf2)); + } if(!p->ascending) result = -result; return result; Modified: dcplusplus/trunk/windows/PublicHubsFrm.cpp =================================================================== --- dcplusplus/trunk/windows/PublicHubsFrm.cpp 2006-02-27 00:04:48 UTC (rev 586) +++ dcplusplus/trunk/windows/PublicHubsFrm.cpp 2006-03-08 22:45:13 UTC (rev 587) @@ -167,8 +167,10 @@ // BAH, sorting on bytes will break of course...oh well...later... if(l->iSubItem == COLUMN_USERS || l->iSubItem == COLUMN_MINSLOTS ||l->iSubItem == COLUMN_MAXHUBS || l->iSubItem == COLUMN_MAXUSERS) { ctrlHubs.setSort(l->iSubItem, ExListViewCtrl::SORT_INT); - } else if(l->iSubItem == COLUMN_SHARED || l->iSubItem == COLUMN_MINSHARE || l->iSubItem == COLUMN_RELIABILITY) { - ctrlHubs.setSort(l->iSubItem, ExListViewCtrl::SORT_FLOAT); + } else if(l->iSubItem == COLUMN_RELIABILITY) { + ctrlHubs.setSort(l->iSubItem, ExListViewCtrl::SORT_FLOAT); + } else if (l->iSubItem == COLUMN_SHARED || l->iSubItem == COLUMN_MINSHARE){ + ctrlHubs.setSort(l->iSubItem, ExListViewCtrl::SORT_BYTES); } else { ctrlHubs.setSort(l->iSubItem, ExListViewCtrl::SORT_STRING_NOCASE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |