mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed bug in GxsIdLabel due to not removign existing jobs for a given widget before setting it to a new ID
This commit is contained in:
parent
6b2de05e89
commit
8f9028dc52
@ -69,6 +69,7 @@ GxsIdDetails::GxsIdDetails()
|
|||||||
{
|
{
|
||||||
mCheckTimerId = 0;
|
mCheckTimerId = 0;
|
||||||
mProcessDisableCount = 0;
|
mProcessDisableCount = 0;
|
||||||
|
mPendingDataIterator = mPendingData.end() ;
|
||||||
|
|
||||||
connect(this, SIGNAL(startTimerFromThread()), this, SLOT(doStartTimer()));
|
connect(this, SIGNAL(startTimerFromThread()), this, SLOT(doStartTimer()));
|
||||||
}
|
}
|
||||||
@ -106,16 +107,16 @@ void GxsIdDetails::objectDestroyed(QObject *object)
|
|||||||
|
|
||||||
/* Object is about to be destroyed, remove it from pending list */
|
/* Object is about to be destroyed, remove it from pending list */
|
||||||
QList<CallbackData>::iterator dataIt;
|
QList<CallbackData>::iterator dataIt;
|
||||||
for (dataIt = mPendingData.begin(); dataIt != mPendingData.end(); ) {
|
|
||||||
CallbackData &pendingData = *dataIt;
|
|
||||||
|
|
||||||
if (pendingData.mObject == object) {
|
QMap<QObject*,CallbackData>::iterator it = mPendingData.find(object) ;
|
||||||
dataIt = mPendingData.erase(dataIt);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++dataIt;
|
if(it != mPendingData.end())
|
||||||
}
|
{
|
||||||
|
if(it == mPendingDataIterator)
|
||||||
|
mPendingDataIterator = mPendingData.erase(it) ;
|
||||||
|
else
|
||||||
|
mPendingData.erase(it) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdDetails::connectObject_locked(QObject *object, bool doConnect)
|
void GxsIdDetails::connectObject_locked(QObject *object, bool doConnect)
|
||||||
@ -125,13 +126,9 @@ void GxsIdDetails::connectObject_locked(QObject *object, bool doConnect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Search Object in pending list */
|
/* Search Object in pending list */
|
||||||
QList<CallbackData>::iterator dataIt;
|
|
||||||
for (dataIt = mPendingData.begin(); dataIt != mPendingData.end(); ++dataIt) {
|
if(mPendingData.find(object) != mPendingData.end())
|
||||||
if (dataIt->mObject == object) {
|
return ;
|
||||||
/* Object still/already in pending list */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doConnect) {
|
if (doConnect) {
|
||||||
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
||||||
@ -155,12 +152,16 @@ void GxsIdDetails::timerEvent(QTimerEvent *event)
|
|||||||
if (!mPendingData.empty()) {
|
if (!mPendingData.empty()) {
|
||||||
/* Check pending id's */
|
/* Check pending id's */
|
||||||
int processed = qMin(MAX_PROCESS_COUNT_PER_TIMER, mPendingData.size());
|
int processed = qMin(MAX_PROCESS_COUNT_PER_TIMER, mPendingData.size());
|
||||||
|
|
||||||
while (!mPendingData.isEmpty()) {
|
while (!mPendingData.isEmpty()) {
|
||||||
if (processed-- <= 0) {
|
if (processed-- <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallbackData &pendingData = mPendingData.front();
|
if(mPendingDataIterator == mPendingData.end())
|
||||||
|
mPendingDataIterator = mPendingData.begin() ;
|
||||||
|
|
||||||
|
CallbackData &pendingData = *mPendingDataIterator;
|
||||||
|
|
||||||
RsIdentityDetails details;
|
RsIdentityDetails details;
|
||||||
if (rsIdentity->getIdDetails(pendingData.mId, details)) {
|
if (rsIdentity->getIdDetails(pendingData.mId, details)) {
|
||||||
@ -168,7 +169,8 @@ void GxsIdDetails::timerEvent(QTimerEvent *event)
|
|||||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_DONE, details, pendingData.mObject, pendingData.mData);
|
pendingData.mCallback(GXS_ID_DETAILS_TYPE_DONE, details, pendingData.mObject, pendingData.mData);
|
||||||
|
|
||||||
QObject *object = pendingData.mObject;
|
QObject *object = pendingData.mObject;
|
||||||
mPendingData.pop_front();
|
mPendingDataIterator = mPendingData.erase(mPendingDataIterator);
|
||||||
|
|
||||||
connectObject_locked(object, false);
|
connectObject_locked(object, false);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -180,13 +182,16 @@ void GxsIdDetails::timerEvent(QTimerEvent *event)
|
|||||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_FAILED, details, pendingData.mObject, pendingData.mData);
|
pendingData.mCallback(GXS_ID_DETAILS_TYPE_FAILED, details, pendingData.mObject, pendingData.mData);
|
||||||
|
|
||||||
QObject *object = pendingData.mObject;
|
QObject *object = pendingData.mObject;
|
||||||
mPendingData.pop_front();
|
mPendingDataIterator = mPendingData.erase(mPendingDataIterator);
|
||||||
|
|
||||||
connectObject_locked(object, false);
|
connectObject_locked(object, false);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPendingData.move(0, mPendingData.size() - 1);
|
++mPendingDataIterator ;
|
||||||
|
|
||||||
|
//mPendingData.move(0, mPendingData.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,6 +251,22 @@ bool GxsIdDetails::process(const RsGxsId &id, GxsIdDetailsCallbackFunction callb
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove any existing call for this object. This is needed for when the same widget is used to display IDs that vary in time.
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&mInstance->mMutex);
|
||||||
|
|
||||||
|
// check if a pending request is not already on its way. If so, replace it.
|
||||||
|
|
||||||
|
QMap<QObject*,CallbackData>::iterator it = mInstance->mPendingData.find(object) ;
|
||||||
|
|
||||||
|
if(it != mInstance->mPendingData.end())
|
||||||
|
{
|
||||||
|
mInstance->connectObject_locked(object, false);
|
||||||
|
mInstance->mPendingData.erase(it) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Connect signal "destroy" */
|
||||||
|
}
|
||||||
/* Try to get the information */
|
/* Try to get the information */
|
||||||
// the idea behind this was, to call the callback directly when the identity is already loaded in librs
|
// the idea behind this was, to call the callback directly when the identity is already loaded in librs
|
||||||
// without one timer tick, but it causes the use of Pixmap in avatars within a threat that is different than
|
// without one timer tick, but it causes the use of Pixmap in avatars within a threat that is different than
|
||||||
@ -277,10 +298,12 @@ bool GxsIdDetails::process(const RsGxsId &id, GxsIdDetailsCallbackFunction callb
|
|||||||
{
|
{
|
||||||
QMutexLocker lock(&mInstance->mMutex);
|
QMutexLocker lock(&mInstance->mMutex);
|
||||||
|
|
||||||
|
// check if a pending request is not already on its way. If so, replace it.
|
||||||
|
|
||||||
|
mInstance->mPendingData[object] = pendingData;
|
||||||
|
|
||||||
/* Connect signal "destroy" */
|
/* Connect signal "destroy" */
|
||||||
mInstance->connectObject_locked(object, true);
|
mInstance->connectObject_locked(object, true);
|
||||||
|
|
||||||
mInstance->mPendingData.push_back(pendingData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start timer */
|
/* Start timer */
|
||||||
|
@ -132,7 +132,8 @@ protected:
|
|||||||
static GxsIdDetails *mInstance;
|
static GxsIdDetails *mInstance;
|
||||||
|
|
||||||
/* Pending data */
|
/* Pending data */
|
||||||
QList<CallbackData> mPendingData;
|
QMap<QObject*,CallbackData> mPendingData;
|
||||||
|
QMap<QObject*,CallbackData>::iterator mPendingDataIterator;
|
||||||
int mCheckTimerId;
|
int mCheckTimerId;
|
||||||
int mProcessDisableCount;
|
int mProcessDisableCount;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user