Commit 56bb5449 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Prevent endless restart of qmlpuppet

parent 8512f1ed
......@@ -46,6 +46,7 @@
#include <QImage>
#include <QWeakPointer>
#include <QRectF>
#include <QTime>
QT_BEGIN_NAMESPACE
class QDeclarativeEngine;
......@@ -165,9 +166,11 @@ private: // functions
void resetHorizontalAnchors(const ModelNode &node);
void resetVerticalAnchors(const ModelNode &node);
private slots:
void restartProcess();
private slots:
void handleChrash();
private: //variables
NodeInstance m_rootNodeInstance;
NodeInstance m_activeStateInstance;
......@@ -178,6 +181,7 @@ private: //variables
uint m_blockUpdates;
QWeakPointer<NodeInstanceServerInterface> m_nodeInstanceServer;
QImage m_baseStatePreviewImage;
QTime m_lastCrashTime;
};
} // namespace ProxyNodeInstanceView
......
......@@ -159,11 +159,12 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
writeCommandToSocket(command, m_secondSocket.data());
}
void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitStatus /* exitStatus */)
void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitStatus exitStatus)
{
m_firstSocket->close();
m_secondSocket->close();
emit processCrashed();
if (exitStatus == QProcess::CrashExit)
emit processCrashed();
}
......
......@@ -142,7 +142,8 @@ void NodeInstanceView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
m_nodeInstanceServer = new NodeInstanceServerProxy(this);
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(restartProcess()));
m_lastCrashTime.start();
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
nodeInstanceServer()->createScene(createCreateSceneCommand());
}
......@@ -155,6 +156,13 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model)
AbstractView::modelAboutToBeDetached(model);
}
void NodeInstanceView::handleChrash()
{
int elaspsedTimeSinceLastCrash = m_lastCrashTime.restart();
if (elaspsedTimeSinceLastCrash > 10000)
restartProcess();
}
void NodeInstanceView::restartProcess()
{
......@@ -162,7 +170,7 @@ void NodeInstanceView::restartProcess()
delete nodeInstanceServer();
m_nodeInstanceServer = new NodeInstanceServerProxy(this);
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(restartProcess()));
connect(m_nodeInstanceServer.data(), SIGNAL(processCrashed()), this, SLOT(handleChrash()));
nodeInstanceServer()->createScene(createCreateSceneCommand());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment