[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Mon Nov 30 19:44:30 CET 2009
SVN commit 1056741 by netterfield:
-Fix memory estimation in the data wizard.
-Add rate limiting to the update manager. Now settings->update period is honored.
M +21 -0 libkst/updatemanager.cpp
M +4 -0 libkst/updatemanager.h
M +0 -8 libkstapp/datawizard.cpp
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #1056740:1056741
@@ -54,12 +54,19 @@
_maxUpdate = MAX_UPDATES;
_paused = false;
_store = 0;
+ _delayedUpdateScheduled = false;
+ _time.start();
}
UpdateManager::~UpdateManager() {
}
+void UpdateManager::delayedUpdates() {
+ _delayedUpdateScheduled = false;
+ doUpdates();
+}
+
void UpdateManager::doUpdates(bool forceImmediate) {
Q_UNUSED(forceImmediate)
@@ -67,6 +74,20 @@
return;
}
+ if (_paused && !forceImmediate) {
+ return;
+ }
+
+ int dT = _time.elapsed();
+ if ((dT<_maxUpdate) && (!forceImmediate)) {
+ if (!_delayedUpdateScheduled) {
+ _delayedUpdateScheduled = true;
+ QTimer::singleShot(_maxUpdate-dT, this, SLOT(delayedUpdates()));
+ }
+ return;
+ }
+ _time.restart();
+
_serial++;
int n_updated=0, n_deferred=0, n_unchanged = 0;
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.h #1056740:1056741
@@ -15,6 +15,7 @@
#include "object.h"
#include <QGraphicsRectItem>
+#include <QTime>
namespace Kst {
class ObjectStore;
@@ -37,6 +38,7 @@
public Q_SLOTS:
void doUpdates(bool forceImmediate = false);
+ void delayedUpdates();
Q_SIGNALS:
void objectsUpdated(qint64 serial);
@@ -45,11 +47,13 @@
UpdateManager();
~UpdateManager();
static void cleanup();
+ QTime _time;
private:
bool _delayedUpdate;
int _maxUpdate;
bool _paused;
+ bool _delayedUpdateScheduled;
qint64 _serial;
ObjectStore *_store;
TabWidget *_tabWidget;
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1056740:1056741
@@ -605,10 +605,6 @@
memoryRequested += frames * ds->samplesPerFrame(_pageDataPresentation->vectorField())*sizeof(double);
}
}
- qDebug() <<
- "memReq: " << memoryRequested <<
- " spf: " << ds->samplesPerFrame(_pageDataPresentation->vectorField()) <<
- " frames: " << frames;
// memory estimate for the y vectors
{
@@ -635,10 +631,6 @@
}
}
}
- qDebug() <<
- "memReq: " << memoryRequested <<
- " spf: " << ds->samplesPerFrame(_pageDataPresentation->vectorField()) <<
- " frames: " << frames;
ds->unlock();
if (memoryRequested > memoryAvailable) {
More information about the Kst
mailing list