forked from qt-creator/qt-creator
QmlDesigner:Compress restartProcess()
Calling restartProcess() is delayed by 100 ms and all subsequent calls in that timeframe are ignored. Change-Id: I59dd2e91475444cea4ee70bafb130213176cb666 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
9bb38f94de
commit
f07e3670c1
@@ -245,6 +245,8 @@ public:
|
||||
|
||||
void resetView();
|
||||
|
||||
void resetPuppet();
|
||||
|
||||
virtual bool hasWidget() const;
|
||||
virtual WidgetInfo widgetInfo();
|
||||
|
||||
|
||||
@@ -140,6 +140,9 @@ signals:
|
||||
void qmlPuppetCrashed();
|
||||
void qmlPuppetError(const QString &errorMessage);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
private: // functions
|
||||
void activateState(const NodeInstance &instance);
|
||||
void activateBaseState();
|
||||
@@ -185,6 +188,7 @@ private: // functions
|
||||
void resetVerticalAnchors(const ModelNode &node);
|
||||
|
||||
void restartProcess();
|
||||
void delayedRestartProcess();
|
||||
|
||||
private slots:
|
||||
void handleChrash();
|
||||
@@ -202,6 +206,7 @@ private: //variables
|
||||
QTime m_lastCrashTime;
|
||||
NodeInstanceServerInterface::RunModus m_runModus;
|
||||
ProjectExplorer::Kit *m_currentKit;
|
||||
int m_restartProcessTimerId;
|
||||
};
|
||||
|
||||
} // namespace ProxyNodeInstanceView
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QMultiHash>
|
||||
#include <QTimerEvent>
|
||||
|
||||
#include <model.h>
|
||||
#include <modelnode.h>
|
||||
@@ -107,7 +108,8 @@ NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface:
|
||||
: AbstractView(parent),
|
||||
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
|
||||
m_runModus(runModus),
|
||||
m_currentKit(0)
|
||||
m_currentKit(0),
|
||||
m_restartProcessTimerId(0)
|
||||
{
|
||||
m_baseStatePreviewImage.fill(0xFFFFFF);
|
||||
}
|
||||
@@ -198,6 +200,9 @@ void NodeInstanceView::handleChrash()
|
||||
|
||||
void NodeInstanceView::restartProcess()
|
||||
{
|
||||
if (m_restartProcessTimerId)
|
||||
killTimer(m_restartProcessTimerId);
|
||||
|
||||
if (model()) {
|
||||
delete nodeInstanceServer();
|
||||
|
||||
@@ -213,6 +218,14 @@ void NodeInstanceView::restartProcess()
|
||||
activateState(newStateInstance);
|
||||
}
|
||||
}
|
||||
|
||||
m_restartProcessTimerId = 0;
|
||||
}
|
||||
|
||||
void NodeInstanceView::delayedRestartProcess()
|
||||
{
|
||||
if (0 == m_restartProcessTimerId)
|
||||
m_restartProcessTimerId = startTimer(100);
|
||||
}
|
||||
|
||||
void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
|
||||
@@ -457,7 +470,7 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const Propert
|
||||
void NodeInstanceView::customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &, const QList<QVariant> &)
|
||||
{
|
||||
if (view && identifier == QStringLiteral("reset QmlPuppet"))
|
||||
restartProcess();
|
||||
delayedRestartProcess();
|
||||
}
|
||||
|
||||
void NodeInstanceView::nodeSourceChanged(const ModelNode &node, const QString & newNodeSource)
|
||||
@@ -1234,4 +1247,10 @@ void NodeInstanceView::sendToken(const QString &token, int number, const QVector
|
||||
nodeInstanceServer()->token(TokenCommand(token, number, instanceIdVector));
|
||||
}
|
||||
|
||||
void NodeInstanceView::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_restartProcessTimerId == event->timerId())
|
||||
restartProcess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -520,6 +520,11 @@ void AbstractView::resetView()
|
||||
currentModel->attachView(this);
|
||||
}
|
||||
|
||||
void AbstractView::resetPuppet()
|
||||
{
|
||||
emitCustomNotification(QStringLiteral("reset QmlPuppet"));
|
||||
}
|
||||
|
||||
bool AbstractView::hasWidget() const
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user