diff --git a/src/plugins/qmldesigner/QmlDesigner.pluginspec.in b/src/plugins/qmldesigner/QmlDesigner.pluginspec.in
index 693fd5f8141..b9fb1896a0d 100644
--- a/src/plugins/qmldesigner/QmlDesigner.pluginspec.in
+++ b/src/plugins/qmldesigner/QmlDesigner.pluginspec.in
@@ -20,4 +20,7 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Visual Designer for QML files.
http://www.qt-project.org
$$dependencyList
+
+ Captures the Qml Puppet stream
+
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
index f366abbb012..b99756e0a4e 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#include "createinstancescommand.h"
#include "createscenecommand.h"
@@ -240,6 +241,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
} else {
QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), missingQmlPuppetErrorMessage(applicationPath));
}
+
+ int indexOfCapturePuppetStream = QCoreApplication::arguments().indexOf("-capture-puppet-stream");
+ if (indexOfCapturePuppetStream > 0) {
+ m_captureFileForTest.setFileName(QCoreApplication::arguments().at(indexOfCapturePuppetStream + 1));
+ bool isOpen = m_captureFileForTest.open(QIODevice::WriteOnly);
+ qDebug() << "file is open: " << isOpen;
+ }
}
NodeInstanceServerProxy::~NodeInstanceServerProxy()
@@ -333,9 +341,9 @@ QString NodeInstanceServerProxy::missingQmlPuppetErrorMessage(const QString &app
return message;
}
-static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket, unsigned int commandCounter)
+static void writeCommandToIODecive(const QVariant &command, QIODevice *ioDevice, unsigned int commandCounter)
{
- if (socket) {
+ if (ioDevice) {
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_8);
@@ -345,22 +353,29 @@ static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket,
out.device()->seek(0);
out << quint32(block.size() - sizeof(quint32));
- socket->write(block);
+ ioDevice->write(block);
}
}
void NodeInstanceServerProxy::writeCommand(const QVariant &command)
{
- writeCommandToSocket(command, m_firstSocket.data(), m_writeCommandCounter);
- writeCommandToSocket(command, m_secondSocket.data(), m_writeCommandCounter);
- writeCommandToSocket(command, m_thirdSocket.data(), m_writeCommandCounter);
+ writeCommandToIODecive(command, m_firstSocket.data(), m_writeCommandCounter);
+ writeCommandToIODecive(command, m_secondSocket.data(), m_writeCommandCounter);
+ writeCommandToIODecive(command, m_thirdSocket.data(), m_writeCommandCounter);
+
+ if (m_captureFileForTest.isWritable()) {
+ qDebug() << "Write strean to file: " << m_captureFileForTest.fileName();
+ writeCommandToIODecive(command, &m_captureFileForTest, m_writeCommandCounter);
+ qDebug() << "\twrite file: " << m_captureFileForTest.pos();
+ }
+
m_writeCommandCounter++;
if (m_runModus == TestModus) {
static int synchronizeId = 0;
synchronizeId++;
SynchronizeCommand synchronizeCommand(synchronizeId);
- writeCommandToSocket(QVariant::fromValue(synchronizeCommand), m_firstSocket.data(), m_writeCommandCounter);
+ writeCommandToIODecive(QVariant::fromValue(synchronizeCommand), m_firstSocket.data(), m_writeCommandCounter);
m_writeCommandCounter++;
while (m_firstSocket->waitForReadyRead(100)) {
@@ -375,6 +390,14 @@ void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitSt
{
qDebug() << "Process finished:" << sender();
+ if (m_captureFileForTest.isOpen()) {
+ m_captureFileForTest.close();
+ m_captureFileForTest.remove();
+ QMessageBox::warning(0, tr("Qml Puppet crashes"), tr("Your are recording a Puppet stream and the puppet crashes. "
+ "It is recommended to reopen the Qml Designer and start again."));
+ }
+
+
writeCommand(QVariant::fromValue(EndPuppetCommand()));
if (m_firstSocket)
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
index d68ff85aacc..a8f0b44ff08 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
@@ -34,6 +34,7 @@
#include
#include
+#include
QT_BEGIN_NAMESPACE
class QLocalServer;
@@ -75,6 +76,8 @@ protected:
void dispatchCommand(const QVariant &command);
NodeInstanceClientInterface *nodeInstanceClient() const;
QString missingQmlPuppetErrorMessage(const QString &applicationPath) const;
+ QString qmlPuppetApplicationName() const;
+ QString macOSBundlePath(const QString &path) const;
signals:
void processCrashed();
@@ -86,9 +89,7 @@ private slots:
void readThirdDataStream();
private:
- QString qmlPuppetApplicationName() const;
- QString macOSBundlePath(const QString &path) const;
-
+ QFile m_captureFileForTest;
QWeakPointer m_localServer;
QWeakPointer m_firstSocket;
QWeakPointer m_secondSocket;
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 94bc843fe23..c03a851c959 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -41,6 +41,7 @@
#include
#include
#include
+#include
#include