ported branch commit 2732: fixed deadlock in passwd callback

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2734 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-04-19 21:50:03 +00:00
parent 768b9288b5
commit 38463c905e
12 changed files with 102 additions and 61 deletions

View file

@ -329,6 +329,9 @@ void MainWindow::displaySystrayMsg(const QString& title,const QString& msg)
void MainWindow::updateStatus()
{
// This call is essential to remove locks due to QEventLoop re-entrance while asking gpg passwds. Dont' remove it!
if(RsAutoUpdatePage::eventsLocked())
return ;
if (ratesstatus)
ratesstatus->getRatesStatus();

View file

@ -969,6 +969,9 @@ void MessengerWindow::loadOwnStatus()
/** Save own status Online,Away,Busy **/
void MessengerWindow::savestatus()
{
if(RsAutoUpdatePage::eventsLocked())
return ;
//rsiface->lockData(); /* Lock Interface */
RsPeerDetails detail;

View file

@ -710,6 +710,9 @@ void NetworkDialog::displayInfoLogMenu(const QPoint& pos) {
void NetworkDialog::getNetworkStatus()
{
if(RsAutoUpdatePage::eventsLocked())
return ;
rsiface->lockData(); /* Lock Interface */
/* now the extra bit .... switch on check boxes */
@ -766,6 +769,9 @@ void NetworkDialog::getNetworkStatus()
void NetworkDialog::updateNetworkStatus()
{
if(RsAutoUpdatePage::eventsLocked())
return ;
rsiface->lockData(); /* Lock Interface */
/* now the extra bit .... switch on check boxes */

View file

@ -3,6 +3,8 @@
#include "RsAutoUpdatePage.h"
#include "MessengerWindow.h"
bool RsAutoUpdatePage::_locked = false ;
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
: MainPage(parent)
{
@ -16,14 +18,15 @@ RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
void RsAutoUpdatePage::showEvent(QShowEvent *event)
{
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
updateDisplay();
if(!_locked)
updateDisplay();
}
void RsAutoUpdatePage::timerUpdate()
{
// only update when the widget is visible.
//
if(!isVisible())
if(_locked || !isVisible())
return ;
updateDisplay();
@ -31,3 +34,6 @@ void RsAutoUpdatePage::timerUpdate()
update() ; // Qt flush
}
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
void RsAutoUpdatePage::unlockAllEvents() { _locked = false ; }
bool RsAutoUpdatePage::eventsLocked() { return _locked ; }

View file

@ -21,6 +21,10 @@ class RsAutoUpdatePage: public MainPage
RsAutoUpdatePage(int ms_update_period = 1000,QWidget *parent=NULL) ;
virtual void updateDisplay() {}
static void lockAllEvents() ;
static void unlockAllEvents() ;
static bool eventsLocked() ;
protected:
virtual void showEvent(QShowEvent *e) ;
@ -30,4 +34,7 @@ class RsAutoUpdatePage: public MainPage
private:
QTimer *_timer ;
static bool _locked ;
};

View file

@ -211,7 +211,7 @@ void StartDialog::notSecureWarning() {
if(ui.autologin_checkbox->isChecked()){
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
tr("Insecure"),
tr("Auto-Login is not Secure \n It can be disabled in General Settings"),
tr("Auto Login is not so much secure:\n - Your SSL certificate will be stored unprotected. \n - Your PGP key will however not be stored.\nThis choice be reverted in settings."),
QMessageBox::Ok);
}

View file

@ -24,6 +24,7 @@
#include <rshare.h>
#include <control/bandwidthevent.h>
#include "bwgraph.h"
#include <gui/RsAutoUpdatePage.h>
#include "rsiface/rsiface.h"
#include <sstream>
@ -119,6 +120,9 @@ BandwidthGraph::timerEvent( QTimerEvent * )
void
BandwidthGraph::updategraphstatus( )
{
if(RsAutoUpdatePage::eventsLocked())
return ;
/* set users/friends/network */
float downKb = 0;
float upKb = 0;

View file

@ -42,13 +42,18 @@ void NotifyQt::notifyOwnAvatarChanged()
emit ownAvatarChanged() ;
}
std::string NotifyQt::askForPassword(const std::string& key_details)
std::string NotifyQt::askForPassword(const std::string& key_details,bool prev_is_bad)
{
return QInputDialog::getText(NULL, tr("GPG key passphrase"),
tr("Please enter the password to unlock the following GPG key:\n") + QString::fromStdString(key_details),
QLineEdit::Password,
NULL, NULL).toStdString();
RsAutoUpdatePage::lockAllEvents() ;
std::string res = QInputDialog::getText(NULL, tr("GPG key passphrase"),
(prev_is_bad?tr("Wrong password !\n\n"):QString()) +
tr("Please enter the password to unlock the following GPG key:\n") + QString::fromStdString(key_details), QLineEdit::Password, NULL, NULL).toStdString();
RsAutoUpdatePage::unlockAllEvents() ;
return res ;
}
void NotifyQt::notifyOwnStatusMessageChanged()

View file

@ -41,7 +41,7 @@ class NotifyQt: public QObject, public NotifyBase
virtual void notifyOwnAvatarChanged() ;
virtual void notifyOwnStatusMessageChanged() ;
virtual std::string askForPassword(const std::string& key_details) ;
virtual std::string askForPassword(const std::string& key_details,bool prev_is_bad) ;
signals:
// It's beneficial to send info to the GUI using signals, because signals are thread-safe