qmlobserver: avoid to stream objects too often.

Limit to once every 5 seconds
This commit is contained in:
Olivier Goffart
2010-08-19 12:47:43 +02:00
parent 0b09a59ef2
commit 812af85d38
2 changed files with 3 additions and 12 deletions

View File

@@ -53,7 +53,6 @@
namespace QmlViewer { namespace QmlViewer {
const int SceneChangeUpdateInterval = 5000; const int SceneChangeUpdateInterval = 5000;
const int MaxSceneChangedTimerRestartCount = 15;
Q_GLOBAL_STATIC(QDeclarativeDesignDebugServer, qmlDesignDebugServer) Q_GLOBAL_STATIC(QDeclarativeDesignDebugServer, qmlDesignDebugServer)
@@ -62,8 +61,7 @@ QDeclarativeDesignViewPrivate::QDeclarativeDesignViewPrivate(QDeclarativeDesignV
designModeBehavior(false), designModeBehavior(false),
executionPaused(false), executionPaused(false),
slowdownFactor(1.0f), slowdownFactor(1.0f),
toolbar(0), toolbar(0)
sceneChangedTimerRestartCount(0)
{ {
sceneChangedTimer.setInterval(SceneChangeUpdateInterval); sceneChangedTimer.setInterval(SceneChangeUpdateInterval);
sceneChangedTimer.setSingleShot(true); sceneChangedTimer.setSingleShot(true);
@@ -536,18 +534,13 @@ void QDeclarativeDesignViewPrivate::_q_sceneChanged(const QList<QRectF> & /*area
if (designModeBehavior) if (designModeBehavior)
return; return;
sceneChangedTimerRestartCount++; if (!sceneChangedTimer.isActive())
if (sceneChangedTimerRestartCount == MaxSceneChangedTimerRestartCount) { sceneChangedTimer.start();
_q_checkSceneItemCount();
}
sceneChangedTimer.start();
} }
void QDeclarativeDesignViewPrivate::_q_checkSceneItemCount() void QDeclarativeDesignViewPrivate::_q_checkSceneItemCount()
{ {
bool hasNewItems = hasNewGraphicsObjects(q->rootObject()); bool hasNewItems = hasNewGraphicsObjects(q->rootObject());
sceneChangedTimerRestartCount = 0;
if (hasNewItems) { if (hasNewItems) {
qmlDesignDebugServer()->sceneItemCountChanged(); qmlDesignDebugServer()->sceneItemCountChanged();
@@ -675,7 +668,6 @@ void QDeclarativeDesignViewPrivate::_q_onStatusChanged(QDeclarativeView::Status
{ {
if (status == QDeclarativeView::Ready) { if (status == QDeclarativeView::Ready) {
if (q->rootObject()) { if (q->rootObject()) {
sceneChangedTimerRestartCount = 0;
hasNewGraphicsObjects(q->rootObject()); hasNewGraphicsObjects(q->rootObject());
if (subcomponentEditorTool->contextIndex() != -1) if (subcomponentEditorTool->contextIndex() != -1)
subcomponentEditorTool->clear(); subcomponentEditorTool->clear();

View File

@@ -83,7 +83,6 @@ public:
qreal slowdownFactor; qreal slowdownFactor;
QmlToolbar *toolbar; QmlToolbar *toolbar;
int sceneChangedTimerRestartCount;
QTimer sceneChangedTimer; QTimer sceneChangedTimer;
QSet<QGraphicsObject *> sceneGraphicsObjects; QSet<QGraphicsObject *> sceneGraphicsObjects;