Switched base class of TokenQueue from QWidget to QObject.

Fixed unlock of the mutex in TokenQueue.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5949 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-12-06 17:51:07 +00:00
parent de757cfcae
commit 0c49fba4d8
2 changed files with 39 additions and 31 deletions

View file

@ -32,7 +32,7 @@
/** Constructor */ /** Constructor */
TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp) TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp)
: QWidget(NULL), mService(service), mResponder(resp) : QObject(NULL), mService(service), mResponder(resp)
{ {
} }
@ -181,10 +181,15 @@ bool TokenQueue::activeRequestExist(const uint32_t& userType)
const TokenRequest& req = *lit; const TokenRequest& req = *lit;
if(req.mUserType == userType) if(req.mUserType == userType)
{
mTokenMtx.unlock();
return true; return true;
} }
}
mTokenMtx.unlock(); mTokenMtx.unlock();
return false;
} }
void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list<uint32_t>& tokens) void TokenQueue::activeRequestTokens(const uint32_t& userType, std::list<uint32_t>& tokens)
@ -231,6 +236,8 @@ bool TokenQueue::cancelRequest(const uint32_t token)
std::cerr << "TokenQueue::cancelRequest() Cleared Request: " << token; std::cerr << "TokenQueue::cancelRequest() Cleared Request: " << token;
std::cerr << std::endl; std::cerr << std::endl;
mTokenMtx.unlock();
return true; return true;
} }
} }

View file

@ -67,7 +67,7 @@ public:
* An important thing to note is that all requests are stacked (so FIFO) * An important thing to note is that all requests are stacked (so FIFO)
* This is to prevent overlapped loads on GXS UIs * This is to prevent overlapped loads on GXS UIs
*/ */
class TokenQueue: public QWidget class TokenQueue: public QObject
{ {
Q_OBJECT Q_OBJECT
@ -102,6 +102,7 @@ public:
bool activeRequestExist(const uint32_t& userType); bool activeRequestExist(const uint32_t& userType);
void activeRequestTokens(const uint32_t& userType, std::list<uint32_t>& tokens); void activeRequestTokens(const uint32_t& userType, std::list<uint32_t>& tokens);
protected: protected:
void doPoll(float dt); void doPoll(float dt);