forked from qt-creator/qt-creator
qmlobserver: avoid to stream objects too often.
Limit to once every 5 seconds
This commit is contained in:
@@ -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();
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user