diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 44e58d12f..baddf4acb 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -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 } diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 7aa68ce01..07b8fc8bc 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -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(); */ diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp index fb8ce1816..1e96c14de 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp @@ -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 ; } + diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index d4af84544..85d984309 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -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() )) ; diff --git a/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h b/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h index 6bb5513fc..562887243 100644 --- a/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h +++ b/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h @@ -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: