mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-21 21:59:02 -04:00
Fixed deadlock in RSGraphWidget (Patch from Cyril)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7908 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0ebc1223b3
commit
6cad38bd7c
2 changed files with 25 additions and 4 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include "RSGraphWidget.h"
|
||||
|
||||
RSGraphSource::RSGraphSource()
|
||||
|
@ -42,7 +43,7 @@ RSGraphSource::RSGraphSource()
|
|||
_timer = new QTimer ;
|
||||
_digits = 2 ;
|
||||
|
||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ;
|
||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateIfPossible())) ;
|
||||
}
|
||||
|
||||
RSGraphSource::~RSGraphSource()
|
||||
|
@ -142,6 +143,14 @@ qint64 RSGraphSource::getTime() const
|
|||
return QDateTime::currentMSecsSinceEpoch() - _time_orig_msecs ;
|
||||
}
|
||||
|
||||
void RSGraphSource::updateIfPossible()
|
||||
{
|
||||
if(RsAutoUpdatePage::eventsLocked())
|
||||
return ;
|
||||
|
||||
update() ;
|
||||
}
|
||||
|
||||
void RSGraphSource::update()
|
||||
{
|
||||
std::map<std::string,float> vals ;
|
||||
|
@ -206,12 +215,23 @@ RSGraphWidget::RSGraphWidget(QWidget *parent)
|
|||
_flags = 0;
|
||||
_time_scale = 5.0f ; // in pixels per second.
|
||||
_timer = new QTimer ;
|
||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ;
|
||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateIfPossible())) ;
|
||||
|
||||
_y_scale = 1.0f ;
|
||||
_timer->start(1000);
|
||||
}
|
||||
|
||||
void RSGraphWidget::updateIfPossible()
|
||||
{
|
||||
if(RsAutoUpdatePage::eventsLocked())
|
||||
return ;
|
||||
|
||||
if(!isVisible())
|
||||
return ;
|
||||
|
||||
update() ;
|
||||
}
|
||||
|
||||
/** Default destructor */
|
||||
RSGraphWidget::~RSGraphWidget()
|
||||
{
|
||||
|
@ -235,7 +255,7 @@ RSGraphWidget::resetGraph()
|
|||
{
|
||||
_source->reset() ;
|
||||
_maxValue = MINUSER_SCALE;
|
||||
update();
|
||||
updateIfPossible();
|
||||
}
|
||||
|
||||
/** Toggles display of respective graph lines and counters. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue