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

QmlDesigner: Prevent endless restart of qmlpuppet

parent 8512f1ed
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <QImage> #include <QImage>
#include <QWeakPointer> #include <QWeakPointer>
#include <QRectF> #include <QRectF>
#include <QTime>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDeclarativeEngine; class QDeclarativeEngine;
...@@ -165,9 +166,11 @@ private: // functions ...@@ -165,9 +166,11 @@ private: // functions
void resetHorizontalAnchors(const ModelNode &node); void resetHorizontalAnchors(const ModelNode &node);
void resetVerticalAnchors(const ModelNode &node); void resetVerticalAnchors(const ModelNode &node);
private slots:
void restartProcess(); void restartProcess();
private slots:
void handleChrash();
private: //variables private: //variables
NodeInstance m_rootNodeInstance; NodeInstance m_rootNodeInstance;
NodeInstance m_activeStateInstance; NodeInstance m_activeStateInstance;
...@@ -178,6 +181,7 @@ private: //variables ...@@ -178,6 +181,7 @@ private: //variables
uint m_blockUpdates; uint m_blockUpdates;
QWeakPointer<NodeInstanceServerInterface> m_nodeInstanceServer; QWeakPointer<NodeInstanceServerInterface> m_nodeInstanceServer;
QImage m_baseStatePreviewImage; QImage m_baseStatePreviewImage;
QTime m_lastCrashTime;
}; };
} // namespace ProxyNodeInstanceView } // namespace ProxyNodeInstanceView
......
...@@ -159,11 +159,12 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command) ...@@ -159,11 +159,12 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
writeCommandToSocket(command, m_secondSocket.data()); 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_firstSocket->close();
m_secondSocket->close(); m_secondSocket->close();
emit processCrashed(); if (exitStatus == QProcess::CrashExit)
emit processCrashed();
} }
......
...@@ -142,7 +142,8 @@ void NodeInstanceView::modelAttached(Model *model) ...@@ -142,7 +142,8 @@ void NodeInstanceView::modelAttached(Model *model)
{ {
AbstractView::modelAttached(model); AbstractView::modelAttached(model);
m_nodeInstanceServer = new NodeInstanceServerProxy(this); 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()); nodeInstanceServer()->createScene(createCreateSceneCommand());
} }
...@@ -155,6 +156,13 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model) ...@@ -155,6 +156,13 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model)
AbstractView::modelAboutToBeDetached(model); AbstractView::modelAboutToBeDetached(model);
} }
void NodeInstanceView::handleChrash()
{
int elaspsedTimeSinceLastCrash = m_lastCrashTime.restart();
if (elaspsedTimeSinceLastCrash > 10000)
restartProcess();
}
void NodeInstanceView::restartProcess() void NodeInstanceView::restartProcess()
{ {
...@@ -162,7 +170,7 @@ void NodeInstanceView::restartProcess() ...@@ -162,7 +170,7 @@ void NodeInstanceView::restartProcess()
delete nodeInstanceServer(); delete nodeInstanceServer();
m_nodeInstanceServer = new NodeInstanceServerProxy(this); 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()); nodeInstanceServer()->createScene(createCreateSceneCommand());
} }
......
Supports Markdown
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