mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-11 16:59:25 -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 <QDateTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||||
#include "RSGraphWidget.h"
|
#include "RSGraphWidget.h"
|
||||||
|
|
||||||
RSGraphSource::RSGraphSource()
|
RSGraphSource::RSGraphSource()
|
||||||
|
@ -42,7 +43,7 @@ RSGraphSource::RSGraphSource()
|
||||||
_timer = new QTimer ;
|
_timer = new QTimer ;
|
||||||
_digits = 2 ;
|
_digits = 2 ;
|
||||||
|
|
||||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ;
|
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateIfPossible())) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RSGraphSource::~RSGraphSource()
|
RSGraphSource::~RSGraphSource()
|
||||||
|
@ -142,6 +143,14 @@ qint64 RSGraphSource::getTime() const
|
||||||
return QDateTime::currentMSecsSinceEpoch() - _time_orig_msecs ;
|
return QDateTime::currentMSecsSinceEpoch() - _time_orig_msecs ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSGraphSource::updateIfPossible()
|
||||||
|
{
|
||||||
|
if(RsAutoUpdatePage::eventsLocked())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
update() ;
|
||||||
|
}
|
||||||
|
|
||||||
void RSGraphSource::update()
|
void RSGraphSource::update()
|
||||||
{
|
{
|
||||||
std::map<std::string,float> vals ;
|
std::map<std::string,float> vals ;
|
||||||
|
@ -206,12 +215,23 @@ RSGraphWidget::RSGraphWidget(QWidget *parent)
|
||||||
_flags = 0;
|
_flags = 0;
|
||||||
_time_scale = 5.0f ; // in pixels per second.
|
_time_scale = 5.0f ; // in pixels per second.
|
||||||
_timer = new QTimer ;
|
_timer = new QTimer ;
|
||||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ;
|
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateIfPossible())) ;
|
||||||
|
|
||||||
_y_scale = 1.0f ;
|
_y_scale = 1.0f ;
|
||||||
_timer->start(1000);
|
_timer->start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSGraphWidget::updateIfPossible()
|
||||||
|
{
|
||||||
|
if(RsAutoUpdatePage::eventsLocked())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
if(!isVisible())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
update() ;
|
||||||
|
}
|
||||||
|
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
RSGraphWidget::~RSGraphWidget()
|
RSGraphWidget::~RSGraphWidget()
|
||||||
{
|
{
|
||||||
|
@ -235,7 +255,7 @@ RSGraphWidget::resetGraph()
|
||||||
{
|
{
|
||||||
_source->reset() ;
|
_source->reset() ;
|
||||||
_maxValue = MINUSER_SCALE;
|
_maxValue = MINUSER_SCALE;
|
||||||
update();
|
updateIfPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggles display of respective graph lines and counters. */
|
/** Toggles display of respective graph lines and counters. */
|
||||||
|
|
|
@ -93,6 +93,7 @@ protected slots:
|
||||||
// Calls the internal source for a new data points; called by the timer. You might want to overload this
|
// Calls the internal source for a new data points; called by the timer. You might want to overload this
|
||||||
// if the collection system needs it. Otherwise, the default method will call getValues()
|
// if the collection system needs it. Otherwise, the default method will call getValues()
|
||||||
void update() ;
|
void update() ;
|
||||||
|
void updateIfPossible() ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void getValues(std::map<std::string,float>& values) const = 0 ;// overload this in your own class to fill in the values you want to display.
|
virtual void getValues(std::map<std::string,float>& values) const = 0 ;// overload this in your own class to fill in the values you want to display.
|
||||||
|
@ -156,7 +157,7 @@ class RSGraphWidget: public QFrame
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void updateDisplay() {}
|
void updateIfPossible() ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Gets the width of the desktop, the max # of points. */
|
/** Gets the width of the desktop, the max # of points. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue