Ensured that inserConnect() is only called when the widget is visible

- added new method RsautoUpdatePage::securedUpdatePage()
- made insertConnect() private to disallow connecting it with callbacks in notifyQt.cpp
- this should also correct some possible deadlocks in passphrase handling
Needs full recompile + qmake of GUI



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6373 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-05-21 12:55:03 +00:00
parent 469b37aa60
commit bb916ad1cc
5 changed files with 27 additions and 19 deletions

View File

@ -184,7 +184,7 @@ void NetworkDialog::changeEvent(QEvent *e)
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::StyleChange:
insertConnect();
securedUpdateDisplay();
break;
default:
// remove compiler warnings
@ -192,13 +192,6 @@ void NetworkDialog::changeEvent(QEvent *e)
}
}
//void NetworkDialog::updateNewDiscoveryInfo()
//{
// //std::cerr << "Received new p3disc info. Updating networkview." << std::endl;
// //networkview->update();
// //networkview->updateDisplay();
//}
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
{
//std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
@ -263,7 +256,7 @@ void NetworkDialog::denyFriend()
std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ;
rsPeers->removeFriend(peer_id) ;
insertConnect() ;
securedUpdateDisplay();
}
void NetworkDialog::deleteCert()
{
@ -276,7 +269,7 @@ void NetworkDialog::deleteCert()
std::string peer_id = wi->text(9).toStdString() ;
rsPeers->deleteCertificate(peer_id) ;
insertConnect() ;
securedUpdateDisplay();
#endif
}

View File

@ -55,7 +55,7 @@ public:
void setBackgroundColorHasSignedMe(QColor color) { mBackgroundColorHasSignedMe = color; }
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
public slots:
private:
void insertConnect();
// std::string loadneighbour();
/* void loadneighbour(); */

View File

@ -23,6 +23,14 @@ RsAutoUpdatePage::~RsAutoUpdatePage()
_timer = NULL ;
}
void RsAutoUpdatePage::securedUpdateDisplay()
{
if(_locked == false && isVisible()) {
updateDisplay();
update() ; // Qt flush
}
}
void RsAutoUpdatePage::showEvent(QShowEvent */*event*/)
{
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
@ -34,14 +42,11 @@ void RsAutoUpdatePage::timerUpdate()
{
// only update when the widget is visible.
//
if(_locked == false && isVisible()) {
updateDisplay();
update() ; // Qt flush
}
securedUpdateDisplay() ;
_timer->start() ;
}
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
void RsAutoUpdatePage::unlockAllEvents() { _locked = false ; }
bool RsAutoUpdatePage::eventsLocked() { return _locked ; }

View File

@ -334,7 +334,7 @@ int main(int argc, char *argv[])
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) ));
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(insertConnect() )) ;
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;

View File

@ -21,13 +21,23 @@ class RsAutoUpdatePage: public MainPage
RsAutoUpdatePage(int ms_update_period = 1000, QWidget *parent = NULL, Qt::WindowFlags flags = 0) ;
virtual ~RsAutoUpdatePage() ;
virtual void updateDisplay() {}
static void lockAllEvents() ;
static void unlockAllEvents() ;
static bool eventsLocked() ;
public slots:
// This method updates the widget only if not locked, and if visible.
// This is *the* method to call when on callbacks etc, to avoid locks due
// to Qt calling itself through recursive behavior such as passphrase
// handling etc.
//
void securedUpdateDisplay() ;
protected:
// This is overloaded in subclasses.
//
virtual void updateDisplay() {}
virtual void showEvent(QShowEvent *e) ;
private slots: