- Moved the created GxsIdRSTreeWidgetItem from the forum fill thread to the main thread so the signal to fill the id can be processed.

- Removed QTimer from GxsIdTreeWidgetItem and GxsIdRSTreeWidgetItem.
- Added new tick signal (every second) on Rshare to fill the id.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6238 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-03-17 16:31:30 +00:00
parent c74a36fff8
commit 813a8fad34
5 changed files with 27 additions and 39 deletions

View File

@ -21,13 +21,15 @@
*
*/
#include "GxsIdTreeWidgetItem.h"
#include "rshare.h"
#include <retroshare/rspeers.h>
#include <iostream>
#define MAX_ATTEMPTS 5
static bool MakeIdDesc(const RsGxsId &id, QString &str)
{
RsIdentityDetails details;
@ -74,26 +76,21 @@ static bool MakeIdDesc(const RsGxsId &id, QString &str)
return true;
}
/** Constructor */
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent)
:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
: QObject(NULL), RSTreeWidgetItem(compareRole, parent), mCount(0), mColumn(0)
{
init();
}
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent)
:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
: QObject(NULL), RSTreeWidgetItem(compareRole, parent), mCount(0), mColumn(0)
{
init();
}
void GxsIdRSTreeWidgetItem::init()
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
}
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
@ -119,11 +116,10 @@ bool GxsIdRSTreeWidgetItem::getId(RsGxsId &id)
return true;
}
#define MAX_ATTEMPTS 5
void GxsIdRSTreeWidgetItem::loadId()
{
disconnect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
std::cerr << " GxsIdRSTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
std::cerr << std::endl;
@ -148,31 +144,25 @@ void GxsIdRSTreeWidgetItem::loadId()
std::cerr << std::endl;
/* timer event to try again */
mTimer->setInterval(mCount * 1000);
mTimer->start();
connect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
}
}
/** Constructor */
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent)
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
: QObject(NULL), QTreeWidgetItem(parent), mCount(0), mColumn(0)
{
init();
}
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent)
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
: QObject(NULL), QTreeWidgetItem(parent), mCount(0), mColumn(0)
{
init();
}
void GxsIdTreeWidgetItem::init()
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
}
void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column)
@ -198,9 +188,10 @@ bool GxsIdTreeWidgetItem::getId(RsGxsId &id)
return true;
}
void GxsIdTreeWidgetItem::loadId()
{
disconnect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
std::cerr << " GxsIdTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
std::cerr << std::endl;
@ -225,7 +216,6 @@ void GxsIdTreeWidgetItem::loadId()
std::cerr << std::endl;
/* timer event to try again */
mTimer->setInterval(mCount * 1000);
mTimer->start();
connect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
}
}

View File

@ -24,20 +24,14 @@
#ifndef _GXS_ID_TREEWIDGETITEM_H
#define _GXS_ID_TREEWIDGETITEM_H
#include <QTimer>
#include <retroshare/rsidentity.h>
#include "gui/common/RSTreeWidgetItem.h"
/*****
* NOTE: I have investigated why the Timer doesn't work in GxsForums.
* It appears that the Timer events occur in the Thread they were created in.
* GxsForums uses a short term thread to fill the ForumThread - this finishes,
* and so the Timer Events don't happen.
*
* The Timer events work fine in Wiki and Comments Dialog.
* because they don't use an additional thread.
*
* NOTE: When the tree item is created within a thread you have to move the object
* with "moveThreadTo()" QObject into the main thread.
* The tick signal to fill the id cannot be processed when the thread is finished.
***/
@ -58,14 +52,11 @@ private slots:
private:
void init();
QTimer *mTimer;
RsGxsId mId;
int mCount;
int mColumn;
};
class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem
{
Q_OBJECT
@ -83,11 +74,9 @@ private slots:
private:
void init();
QTimer *mTimer;
RsGxsId mId;
int mCount;
int mColumn;
};
#endif

View File

@ -713,10 +713,10 @@ void GxsForumThreadWidget::fillThreadFinished()
// clear list
thread->mItems.clear();
} else {
fillThreads (thread->mItems, thread->mExpandNewMessages, thread->mItemToExpand);
fillThreads(thread->mItems, thread->mExpandNewMessages, thread->mItemToExpand);
// cleanup list
cleanupItems (thread->mItems);
cleanupItems(thread->mItems);
}
ui->threadTreeWidget->setSortingEnabled(true);
@ -792,6 +792,8 @@ void GxsForumThreadWidget::forceUpdateDisplay()
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
{
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
item->moveToThread(ui->threadTreeWidget->thread());
QString text;
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));

View File

@ -598,6 +598,11 @@ void Rshare::blinkTimer()
{
mBlink = !mBlink;
emit blink(mBlink);
if (mBlink) {
/* Tick every second (create an own timer when needed) */
emit secondTick();
}
}
bool Rshare::loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId)

View File

@ -139,6 +139,8 @@ signals:
void shutdown();
/** Global blink timer */
void blink(bool on);
/** Global timer every second */
void secondTick();
protected:
#if defined(Q_OS_WIN)