forked from qt-creator/qt-creator
QmlDesigner: Add PuppetAlive command
The puppet can be dead but we don't now. Now the puppet is sending a alive signal. If the signal is not arriving anymore we restart the puppets. Task-number: QTCREATORBUG-12434 Change-Id: I90edab6a45f95950fd764adcb125068659d5354b Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
56
share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h
Normal file
56
share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h
Normal file
@@ -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 <QMetaType>
|
||||
#include <QDebug>
|
||||
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QHash>
|
||||
#include <QWeakPointer>
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
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;
|
||||
|
||||
@@ -43,6 +43,7 @@ class ComponentCompletedCommand;
|
||||
class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
class DebugOutputCommand;
|
||||
class PuppetAliveCommand;
|
||||
|
||||
class NodeInstanceClientInterface
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "endpuppetcommand.h"
|
||||
#include "debugoutputcommand.h"
|
||||
#include "puppetalivecommand.h"
|
||||
|
||||
#include <enumeration.h>
|
||||
|
||||
@@ -186,6 +187,9 @@ void NodeInstanceServerInterface::registerCommands()
|
||||
|
||||
qRegisterMetaType<Enumeration>("Enumeration");
|
||||
qRegisterMetaTypeStreamOperators<Enumeration>("Enumeration");
|
||||
|
||||
qRegisterMetaType<PuppetAliveCommand>("PuppetAliveCommand");
|
||||
qRegisterMetaTypeStreamOperators<PuppetAliveCommand>("PuppetAliveCommand");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<InformationChangedCommand>());
|
||||
@@ -258,6 +267,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
|
||||
nodeInstanceClient()->token(command.value<TokenCommand>());
|
||||
} else if (command.userType() == debugOutputCommandType) {
|
||||
nodeInstanceClient()->debugOutput(command.value<DebugOutputCommand>());
|
||||
} else if (command.userType() == puppetAliveCommandType) {
|
||||
puppetAlive(puppetStreamType);
|
||||
} else if (command.userType() == synchronizeCommandType) {
|
||||
SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QPointer>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
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<QLocalServer> m_localServer;
|
||||
QPointer<QLocalSocket> m_firstSocket;
|
||||
QPointer<QLocalSocket> m_secondSocket;
|
||||
|
||||
Reference in New Issue
Block a user