diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index 3d347f73dbe0f207de35606db6b36e48a2ff542a..3bf0305103f132d4ed5a25ba8de071c9e033c111 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -25,6 +25,7 @@ HEADERS += $$PWD/reparentinstancescommand.h HEADERS += $$PWD/valueschangedcommand.h HEADERS += $$PWD/changeauxiliarycommand.h HEADERS += $$PWD/removesharedmemorycommand.h +HEADERS += $$PWD/puppetalivecommand.h SOURCES += $$PWD/synchronizecommand.cpp SOURCES += $$PWD/debugoutputcommand.cpp @@ -51,3 +52,4 @@ SOURCES += $$PWD/createscenecommand.cpp SOURCES += $$PWD/pixmapchangedcommand.cpp SOURCES += $$PWD/changeauxiliarycommand.cpp SOURCES += $$PWD/removesharedmemorycommand.cpp +SOURCES += $$PWD/puppetalivecommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13fff5fbecdd0cefadb895bc9e80d26c59f90b60 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "puppetalivecommand.h" + +namespace QmlDesigner { + +PuppetAliveCommand::PuppetAliveCommand() +{ +} + +QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &command) +{ + return out; +} + +QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command) +{ + return in; +} + +QDebug operator <<(QDebug debug, const PuppetAliveCommand &command) +{ + return debug.nospace() << "PuppetAliveCommand()"; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h new file mode 100644 index 0000000000000000000000000000000000000000..9d42563769c06cd7356c6c6fc5f207be4363ceae --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef PUPPETALIVECOMMAND_H +#define PUPPETALIVECOMMAND_H + +#include +#include + +namespace QmlDesigner { + +class PuppetAliveCommand +{ + friend QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command); + friend QDebug operator <<(QDebug debug, const PuppetAliveCommand &command); + +public: + PuppetAliveCommand(); +}; + +QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &command); +QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command); + +QDebug operator <<(QDebug debug, const PuppetAliveCommand &command); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::PuppetAliveCommand) + +#endif // PUPPETALIVECOMMAND_H diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index f10d7330b00117ccd38ef7736661700e60584ca1..0d1a17d45f439d939ca7520e17edcb7887f0057e 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -70,6 +70,7 @@ #include "changenodesourcecommand.h" #include "endpuppetcommand.h" #include "debugoutputcommand.h" +#include "puppetalivecommand.h" namespace QmlDesigner { @@ -81,6 +82,9 @@ NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) m_writeCommandCounter(0), m_synchronizeId(-1) { + connect(&m_puppetAliveTimer, SIGNAL(timeout()), this, SLOT(sendPuppetAliveCommand())); + m_puppetAliveTimer.setInterval(300); + m_puppetAliveTimer.start(); } void NodeInstanceClientProxy::initializeSocket() @@ -227,6 +231,11 @@ void NodeInstanceClientProxy::debugOutput(const DebugOutputCommand &command) writeCommand(QVariant::fromValue(command)); } +void NodeInstanceClientProxy::puppetAlive(const PuppetAliveCommand &command) +{ + writeCommand(QVariant::fromValue(command)); +} + void NodeInstanceClientProxy::flush() { } @@ -302,6 +311,11 @@ void NodeInstanceClientProxy::readDataStream() } } +void NodeInstanceClientProxy::sendPuppetAliveCommand() +{ + puppetAlive(PuppetAliveCommand()); +} + NodeInstanceServerInterface *NodeInstanceClientProxy::nodeInstanceServer() const { return m_nodeInstanceServer; diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index 8622c802598882a605aebb38680c9ff34b404098..5349460f4b5b387dec6863681f64e64dd2dda218 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -36,6 +36,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE class QLocalSocket; @@ -77,6 +78,7 @@ public: void componentCompleted(const ComponentCompletedCommand &command); void token(const TokenCommand &command); void debugOutput(const DebugOutputCommand &command); + void puppetAlive(const PuppetAliveCommand &command); void flush(); void synchronizeWithClientProcess(); @@ -111,9 +113,11 @@ protected: protected slots: void readDataStream(); + void sendPuppetAliveCommand(); private: QFile m_controlStream; + QTimer m_puppetAliveTimer; QIODevice *m_inputIoDevice; QIODevice *m_outputIoDevice; NodeInstanceServerInterface *m_nodeInstanceServer; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index 7eeba652a303689668af30fe591837576f4cdd7e..d71503014325a2de22d99f6b2bc8bc73a77f50d5 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -43,6 +43,7 @@ class ComponentCompletedCommand; class TokenCommand; class RemoveSharedMemoryCommand; class DebugOutputCommand; +class PuppetAliveCommand; class NodeInstanceClientInterface { diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp index 791e9d23ebccf7d8d399b6468b8ee9062885ed2f..497d06312e5e6d5fbd53368b44be0bda8e1c63bd 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -62,6 +62,7 @@ #include "removesharedmemorycommand.h" #include "endpuppetcommand.h" #include "debugoutputcommand.h" +#include "puppetalivecommand.h" #include @@ -186,6 +187,9 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType("Enumeration"); qRegisterMetaTypeStreamOperators("Enumeration"); + + qRegisterMetaType("PuppetAliveCommand"); + qRegisterMetaTypeStreamOperators("PuppetAliveCommand"); } } diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 17c17fb3192096fb37d82f2a65df404e417cb813..ff635c36634df982fb360e3fe7aaff9d6e274a68 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -191,6 +191,14 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV bool isOpen = m_captureFileForTest.open(QIODevice::WriteOnly); qDebug() << "file is open: " << isOpen; } + + m_firstTimer.setInterval(3000); + m_secondTimer.setInterval(3000); + m_thirdTimer.setInterval(3000); + + connect(&m_firstTimer, SIGNAL(timeout()), this, SLOT(processFinished())); + connect(&m_secondTimer, SIGNAL(timeout()), this, SLOT(processFinished())); + connect(&m_thirdTimer, SIGNAL(timeout()), this, SLOT(processFinished())); } NodeInstanceServerProxy::~NodeInstanceServerProxy() @@ -230,7 +238,7 @@ NodeInstanceServerProxy::~NodeInstanceServerProxy() } } -void NodeInstanceServerProxy::dispatchCommand(const QVariant &command) +void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStreamType puppetStreamType) { static const int informationChangedCommandType = QMetaType::type("InformationChangedCommand"); static const int valuesChangedCommandType = QMetaType::type("ValuesChangedCommand"); @@ -241,6 +249,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command) static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); static const int tokenCommandType = QMetaType::type("TokenCommand"); static const int debugOutputCommandType = QMetaType::type("DebugOutputCommand"); + static const int puppetAliveCommandType = QMetaType::type("PuppetAliveCommand"); if (command.userType() == informationChangedCommandType) { nodeInstanceClient()->informationChanged(command.value()); @@ -258,6 +267,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command) nodeInstanceClient()->token(command.value()); } else if (command.userType() == debugOutputCommandType) { nodeInstanceClient()->debugOutput(command.value()); + } else if (command.userType() == puppetAliveCommandType) { + puppetAlive(puppetStreamType); } else if (command.userType() == synchronizeCommandType) { SynchronizeCommand synchronizeCommand = command.value(); m_synchronizeId = synchronizeCommand.synchronizeId(); @@ -270,6 +281,31 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const return m_nodeInstanceView.data(); } +void NodeInstanceServerProxy::puppetAlive(NodeInstanceServerProxy::PuppetStreamType puppetStreamType) +{ + switch (puppetStreamType) { + case FirstPuppetStream: + m_firstTimer.stop(); + m_firstTimer.start(); + break; + case SecondPuppetStream: + m_secondTimer.stop(); + m_secondTimer.start(); + break; + case ThirdPuppetStream: + m_thirdTimer.stop(); + m_thirdTimer.start(); + break; + default: + break; + } +} + +void NodeInstanceServerProxy::processFinished() +{ + processFinished(-1, QProcess::CrashExit); +} + static void writeCommandToIODecive(const QVariant &command, QIODevice *ioDevice, unsigned int commandCounter) { if (ioDevice) { @@ -383,7 +419,7 @@ void NodeInstanceServerProxy::readFirstDataStream() } foreach (const QVariant &command, commandList) { - dispatchCommand(command); + dispatchCommand(command, FirstPuppetStream); } } @@ -420,7 +456,7 @@ void NodeInstanceServerProxy::readSecondDataStream() } foreach (const QVariant &command, commandList) { - dispatchCommand(command); + dispatchCommand(command, SecondPuppetStream); } } @@ -457,7 +493,7 @@ void NodeInstanceServerProxy::readThirdDataStream() } foreach (const QVariant &command, commandList) { - dispatchCommand(command); + dispatchCommand(command, ThirdPuppetStream); } } diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h index 9753fb710f766b6f823f51927360910b985ce520..94a87ea066ccbfc300b26823844947656d03d3d5 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h @@ -35,6 +35,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE class QLocalServer; @@ -55,7 +56,14 @@ class NodeInstanceClientProxy; class NodeInstanceServerProxy : public NodeInstanceServerInterface { Q_OBJECT + public: + enum PuppetStreamType { + FirstPuppetStream, + SecondPuppetStream, + ThirdPuppetStream, + }; + explicit NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus = NormalModus, ProjectExplorer::Kit *kit = 0); ~NodeInstanceServerProxy(); void createInstances(const CreateInstancesCommand &command); @@ -77,13 +85,15 @@ public: protected: void writeCommand(const QVariant &command); - void dispatchCommand(const QVariant &command); + void dispatchCommand(const QVariant &command, PuppetStreamType puppetStreamType); NodeInstanceClientInterface *nodeInstanceClient() const; + void puppetAlive(PuppetStreamType puppetStreamType); signals: void processCrashed(); private slots: + void processFinished(); void processFinished(int exitCode, QProcess::ExitStatus exitStatus); void readFirstDataStream(); void readSecondDataStream(); @@ -94,6 +104,9 @@ private slots: void printRenderProcessOutput(); private: QFile m_captureFileForTest; + QTimer m_firstTimer; + QTimer m_secondTimer; + QTimer m_thirdTimer; QPointer m_localServer; QPointer m_firstSocket; QPointer m_secondSocket;