forked from qt-creator/qt-creator
QmlDesigner.NodeInstances: Shared memory for value changes
Change-Id: I3c3455f411f18322a062f144e98461691d12ada8 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -22,7 +22,7 @@ HEADERS += $$PWD/removepropertiescommand.h
|
||||
HEADERS += $$PWD/reparentinstancescommand.h
|
||||
HEADERS += $$PWD/valueschangedcommand.h
|
||||
HEADERS += $$PWD/changeauxiliarycommand.h
|
||||
|
||||
HEADERS += $$PWD/removesharedmemorycommand.h
|
||||
|
||||
SOURCES += $$PWD/synchronizecommand.cpp
|
||||
SOURCES += $$PWD/tokencommand.cpp
|
||||
@@ -46,3 +46,4 @@ SOURCES += $$PWD/createinstancescommand.cpp
|
||||
SOURCES += $$PWD/createscenecommand.cpp
|
||||
SOURCES += $$PWD/pixmapchangedcommand.cpp
|
||||
SOURCES += $$PWD/changeauxiliarycommand.cpp
|
||||
SOURCES += $$PWD/removesharedmemorycommand.cpp
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
RemoveSharedMemoryCommand::RemoveSharedMemoryCommand()
|
||||
{
|
||||
}
|
||||
|
||||
RemoveSharedMemoryCommand::RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector)
|
||||
: m_typeName(typeName),
|
||||
m_keyNumberVector(keyNumberVector)
|
||||
{
|
||||
}
|
||||
|
||||
QString RemoveSharedMemoryCommand::typeName() const
|
||||
{
|
||||
return m_typeName;
|
||||
}
|
||||
|
||||
QVector<qint32> RemoveSharedMemoryCommand::keyNumbers() const
|
||||
{
|
||||
return m_keyNumberVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
out << command.typeName();
|
||||
out << command.keyNumbers();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
in >> command.m_typeName;
|
||||
in >> command.m_keyNumberVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef QMLDESIGNER_REMOVESHAREDMEMORYCOMMAND_H
|
||||
#define QMLDESIGNER_REMOVESHAREDMEMORYCOMMAND_H
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class RemoveSharedMemoryCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command);
|
||||
|
||||
public:
|
||||
RemoveSharedMemoryCommand();
|
||||
RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector);
|
||||
|
||||
QString typeName() const;
|
||||
QVector<qint32> keyNumbers() const;
|
||||
|
||||
private:
|
||||
QString m_typeName;
|
||||
QVector<qint32> m_keyNumberVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::RemoveSharedMemoryCommand)
|
||||
|
||||
#endif // QMLDESIGNER_REMOVESHAREDMEMORYCOMMAND_H
|
@@ -30,14 +30,21 @@
|
||||
|
||||
#include "valueschangedcommand.h"
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QCache>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static QCache<qint32, QSharedMemory> globalSharedMemoryCache(10000);
|
||||
|
||||
ValuesChangedCommand::ValuesChangedCommand()
|
||||
: m_keyNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
ValuesChangedCommand::ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector)
|
||||
: m_valueChangeVector (valueChangeVector)
|
||||
: m_valueChangeVector (valueChangeVector),
|
||||
m_keyNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,17 +53,87 @@ QVector<PropertyValueContainer> ValuesChangedCommand::valueChanges() const
|
||||
return m_valueChangeVector;
|
||||
}
|
||||
|
||||
quint32 ValuesChangedCommand::keyNumber() const
|
||||
{
|
||||
return m_keyNumber;
|
||||
}
|
||||
|
||||
void ValuesChangedCommand::removeSharedMemorys(const QVector<qint32> &keyNumberVector)
|
||||
{
|
||||
foreach (qint32 keyNumber, keyNumberVector) {
|
||||
QSharedMemory *sharedMemory = globalSharedMemoryCache.take(keyNumber);
|
||||
delete sharedMemory;
|
||||
}
|
||||
}
|
||||
|
||||
static const QLatin1String valueKeyTemplateString("Values-%1");
|
||||
|
||||
static QSharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
{
|
||||
QSharedMemory *sharedMemory = new QSharedMemory(QString(valueKeyTemplateString).arg(key));
|
||||
|
||||
bool sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
if (!sharedMemoryIsCreated) {
|
||||
if (sharedMemory->isAttached())
|
||||
sharedMemory->attach();
|
||||
sharedMemory->detach();
|
||||
sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
}
|
||||
|
||||
if (sharedMemoryIsCreated) {
|
||||
globalSharedMemoryCache.insert(key, sharedMemory);
|
||||
return sharedMemory;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
|
||||
{
|
||||
if (command.valueChanges().count() > 5) {
|
||||
static quint32 keyCounter = 0;
|
||||
++keyCounter;
|
||||
command.m_keyNumber = keyCounter;
|
||||
QByteArray outDataStreamByteArray;
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly);
|
||||
|
||||
temporaryOutDataStream << command.valueChanges();;
|
||||
|
||||
QSharedMemory *sharedMemory = createSharedMemory(keyCounter, outDataStreamByteArray.size());
|
||||
|
||||
if (sharedMemory) {
|
||||
qMemCopy(sharedMemory->data(), outDataStreamByteArray.constData(), sharedMemory->size());
|
||||
out << command.keyNumber();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
out << qint32(0);
|
||||
out << command.valueChanges();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void readSharedMemory(qint32 key, QVector<PropertyValueContainer> *valueChangeVector)
|
||||
{
|
||||
QSharedMemory sharedMemory(QString(valueKeyTemplateString).arg(key));
|
||||
bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly);
|
||||
|
||||
if (canAttach) {
|
||||
QDataStream in(QByteArray::fromRawData(static_cast<const char*>(sharedMemory.constData()), sharedMemory.size()));
|
||||
in >> *valueChangeVector;
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command)
|
||||
{
|
||||
in >> command.m_valueChangeVector;
|
||||
in >> command.m_keyNumber;
|
||||
|
||||
if (command.keyNumber() > 0) {
|
||||
readSharedMemory(command.keyNumber(), &command.m_valueChangeVector);
|
||||
} else {
|
||||
in >> command.m_valueChangeVector;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ namespace QmlDesigner {
|
||||
|
||||
class ValuesChangedCommand
|
||||
{
|
||||
friend QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command);
|
||||
friend QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command);
|
||||
|
||||
public:
|
||||
@@ -47,9 +48,13 @@ public:
|
||||
ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector);
|
||||
|
||||
QVector<PropertyValueContainer> valueChanges() const;
|
||||
quint32 keyNumber() const;
|
||||
|
||||
static void removeSharedMemorys(const QVector<qint32> &keyNumberVector);
|
||||
|
||||
private:
|
||||
QVector<PropertyValueContainer> m_valueChangeVector;
|
||||
mutable quint32 m_keyNumber;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command);
|
||||
|
@@ -33,18 +33,25 @@
|
||||
#include <QSharedMemory>
|
||||
#include <QCache>
|
||||
|
||||
#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
|
||||
#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
|
||||
#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
|
||||
#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static QCache<qint32, QSharedMemory> globalSharedMemoryCache(10000);
|
||||
|
||||
ImageContainer::ImageContainer()
|
||||
: m_instanceId(-1)
|
||||
: m_instanceId(-1),
|
||||
m_keyNumber(-2)
|
||||
{
|
||||
}
|
||||
|
||||
ImageContainer::ImageContainer(qint32 instanceId, const QImage &image)
|
||||
ImageContainer::ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber)
|
||||
: m_image(image),
|
||||
m_instanceId(instanceId)
|
||||
m_instanceId(instanceId),
|
||||
m_keyNumber(keyNumber)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,16 +65,46 @@ QImage ImageContainer::image() const
|
||||
return m_image;
|
||||
}
|
||||
|
||||
qint32 ImageContainer::keyNumber() const
|
||||
{
|
||||
return m_keyNumber;
|
||||
}
|
||||
|
||||
void ImageContainer::setImage(const QImage &image)
|
||||
{
|
||||
QTC_ASSERT(m_image.isNull(), /**/);
|
||||
|
||||
m_image = image;
|
||||
}
|
||||
|
||||
void ImageContainer::removeSharedMemorys(const QVector<qint32> &keyNumberVector)
|
||||
{
|
||||
foreach (qint32 keyNumber, keyNumberVector) {
|
||||
QSharedMemory *sharedMemory = globalSharedMemoryCache.take(keyNumber);
|
||||
delete sharedMemory;
|
||||
}
|
||||
}
|
||||
|
||||
static const QLatin1String imageKeyTemplateString("Image-%1");
|
||||
|
||||
static QSharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
{
|
||||
QSharedMemory *sharedMemory = globalSharedMemoryCache.take(key);
|
||||
|
||||
if (sharedMemory == 0)
|
||||
sharedMemory = new QSharedMemory(QString("Image-%1").arg(key));
|
||||
sharedMemory = new QSharedMemory(QString(imageKeyTemplateString).arg(key));
|
||||
|
||||
if (sharedMemory->isAttached())
|
||||
bool sharedMemoryIsCreated = sharedMemory->isAttached();
|
||||
if (!sharedMemoryIsCreated)
|
||||
sharedMemoryIsCreated = sharedMemory->attach();
|
||||
|
||||
bool sharedMemorySizeIsSmallerThanByteCount = sharedMemory->size() < byteCount;
|
||||
bool sharedMemorySizeIsDoubleBiggerThanByteCount = sharedMemory->size() * 2 > byteCount;
|
||||
|
||||
if (!sharedMemoryIsCreated || sharedMemorySizeIsSmallerThanByteCount || sharedMemorySizeIsDoubleBiggerThanByteCount) {
|
||||
sharedMemory->detach();
|
||||
|
||||
bool sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
sharedMemoryIsCreated = sharedMemory->create(byteCount);
|
||||
}
|
||||
|
||||
if (sharedMemoryIsCreated) {
|
||||
globalSharedMemoryCache.insert(key, sharedMemory);
|
||||
@@ -77,69 +114,111 @@ static QSharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
|
||||
static void writeSharedMemory(QSharedMemory *sharedMemory, const QImage &image)
|
||||
{
|
||||
out << container.instanceId();
|
||||
sharedMemory->lock();
|
||||
|
||||
const QImage image = container.image();
|
||||
const QByteArray data(reinterpret_cast<const char*>(image.constBits()), image.byteCount());
|
||||
qint32 headerData[5];
|
||||
headerData[0] = image.byteCount();
|
||||
headerData[1] = image.bytesPerLine();
|
||||
headerData[2] = image.size().width();
|
||||
headerData[3] = image.size().height();
|
||||
headerData[4] = image.format();
|
||||
|
||||
qMemCopy(sharedMemory->data(), headerData, 20);
|
||||
qMemCopy(reinterpret_cast<char*>(sharedMemory->data()) + 20, image.constBits(), image.byteCount());
|
||||
|
||||
sharedMemory->unlock();
|
||||
}
|
||||
|
||||
static void writeStream(QDataStream &out, const QImage &image)
|
||||
{
|
||||
out << qint32(image.bytesPerLine());
|
||||
out << image.size();
|
||||
out << qint32(image.format());
|
||||
out << qint32(image.byteCount());
|
||||
out.writeRawData(reinterpret_cast<const char*>(image.constBits()), image.byteCount());
|
||||
}
|
||||
|
||||
QSharedMemory *sharedMemory = createSharedMemory(container.instanceId(), image.byteCount());
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
|
||||
{
|
||||
const int extraDataSize = 20;
|
||||
|
||||
out << container.instanceId();
|
||||
out << container.keyNumber();
|
||||
|
||||
const QImage image = container.image();
|
||||
QSharedMemory *sharedMemory = createSharedMemory(container.keyNumber(), image.byteCount() + extraDataSize);
|
||||
|
||||
out << qint32(sharedMemory != 0); // send if shared memory is used
|
||||
|
||||
if (sharedMemory) {
|
||||
sharedMemory->lock();
|
||||
qMemCopy(sharedMemory->data(), image.constBits(), image.byteCount());
|
||||
sharedMemory->unlock();
|
||||
} else {
|
||||
out.writeRawData(reinterpret_cast<const char*>(image.constBits()), image.byteCount());
|
||||
}
|
||||
|
||||
if (sharedMemory)
|
||||
writeSharedMemory(sharedMemory, image);
|
||||
else
|
||||
writeStream(out, image);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void readSharedMemory(qint32 key, QImage *image, qint32 byteSize)
|
||||
static void readSharedMemory(qint32 key, ImageContainer &container)
|
||||
{
|
||||
QSharedMemory sharedMemory(QString("Image-%1").arg(key));
|
||||
QSharedMemory sharedMemory(QString(imageKeyTemplateString).arg(key));
|
||||
|
||||
bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly);
|
||||
if (canAttach)
|
||||
|
||||
if (canAttach && sharedMemory.size() >= 20)
|
||||
{
|
||||
sharedMemory.lock();
|
||||
qMemCopy(image->bits(), sharedMemory.constData(), byteSize);
|
||||
qint32 headerData[5];
|
||||
qMemCopy(headerData, sharedMemory.constData(), 20);
|
||||
|
||||
qint32 byteCount = headerData[0];
|
||||
// qint32 bytesPerLine = headerData[1];
|
||||
qint32 imageWidth = headerData[2];
|
||||
qint32 imageHeight = headerData[3];
|
||||
qint32 imageFormat = headerData[4];
|
||||
|
||||
QImage image = QImage(imageWidth, imageHeight, QImage::Format(imageFormat));
|
||||
|
||||
qMemCopy(image.bits(), reinterpret_cast<const qint32*>(sharedMemory.constData()) + 5, byteCount);
|
||||
|
||||
container.setImage(image);
|
||||
|
||||
sharedMemory.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ImageContainer &container)
|
||||
static void readStream(QDataStream &in, ImageContainer &container)
|
||||
{
|
||||
|
||||
qint32 byteSize;
|
||||
qint32 byteCount;
|
||||
qint32 bytesPerLine;
|
||||
QSize imageSize;
|
||||
qint32 format;
|
||||
qint32 sharedmemoryIsUsed;
|
||||
|
||||
in >> container.m_instanceId;
|
||||
qint32 imageFormat;
|
||||
|
||||
in >> bytesPerLine;
|
||||
in >> imageSize;
|
||||
in >> format;
|
||||
in >> byteSize;
|
||||
in >> sharedmemoryIsUsed;
|
||||
in >> imageFormat;
|
||||
in >> byteCount;
|
||||
|
||||
container.m_image = QImage(imageSize, QImage::Format(format));
|
||||
QImage image = QImage(imageSize, QImage::Format(imageFormat));
|
||||
|
||||
if (sharedmemoryIsUsed)
|
||||
readSharedMemory(container.instanceId(), &container.m_image, byteSize);
|
||||
else
|
||||
in.readRawData(reinterpret_cast<char*>(container.m_image.bits()), byteSize);
|
||||
in.readRawData(reinterpret_cast<char*>(image.bits()), byteCount);
|
||||
|
||||
container.setImage(image);
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, ImageContainer &container)
|
||||
{
|
||||
qint32 sharedMemoryIsUsed;
|
||||
|
||||
in >> container.m_instanceId;
|
||||
in >> container.m_keyNumber;
|
||||
in >> sharedMemoryIsUsed;
|
||||
|
||||
if (sharedMemoryIsUsed) {
|
||||
readSharedMemory(container.keyNumber(), container);
|
||||
} else
|
||||
readStream(in, container);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@@ -41,14 +41,20 @@ class ImageContainer
|
||||
friend QDataStream &operator>>(QDataStream &in, ImageContainer &container);
|
||||
public:
|
||||
ImageContainer();
|
||||
ImageContainer(qint32 instanceId, const QImage &image);
|
||||
ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber);
|
||||
|
||||
qint32 instanceId() const;
|
||||
QImage image() const;
|
||||
qint32 keyNumber() const;
|
||||
|
||||
void setImage(const QImage &image);
|
||||
|
||||
static void removeSharedMemorys(const QVector<qint32> &keyNumberVector);
|
||||
|
||||
private:
|
||||
QImage m_image;
|
||||
qint32 m_instanceId;
|
||||
qint32 m_keyNumber;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container);
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include "changestatecommand.h"
|
||||
#include "completecomponentcommand.h"
|
||||
#include "synchronizecommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "tokencommand.h"
|
||||
|
||||
#include "informationchangedcommand.h"
|
||||
@@ -274,6 +275,11 @@ void NodeInstanceClientProxy::changeNodeSource(const ChangeNodeSourceCommand &co
|
||||
{
|
||||
nodeInstanceServer()->changeNodeSource(command);
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
nodeInstanceServer()->removeSharedMemory(command);
|
||||
}
|
||||
void NodeInstanceClientProxy::redirectToken(const TokenCommand &command)
|
||||
{
|
||||
nodeInstanceServer()->token(command);
|
||||
@@ -296,6 +302,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
static const int completeComponentCommandType = QMetaType::type("CompleteComponentCommand");
|
||||
static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand");
|
||||
static const int changeNodeSourceCommandType = QMetaType::type("ChangeNodeSourceCommand");
|
||||
static const int removeSharedMemoryCommandType = QMetaType::type("RemoveSharedMemoryCommand");
|
||||
static const int tokenCommandType = QMetaType::type("TokenCommand");
|
||||
|
||||
if (command.userType() == createInstancesCommandType) {
|
||||
@@ -326,6 +333,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
completeComponent(command.value<CompleteComponentCommand>());
|
||||
else if (command.userType() == changeNodeSourceCommandType)
|
||||
changeNodeSource(command.value<ChangeNodeSourceCommand>());
|
||||
else if (command.userType() == removeSharedMemoryCommandType)
|
||||
removeSharedMemory(command.value<RemoveSharedMemoryCommand>());
|
||||
else if (command.userType() == tokenCommandType)
|
||||
redirectToken(command.value<TokenCommand>());
|
||||
else if (command.userType() == synchronizeCommandType) {
|
||||
|
@@ -100,6 +100,7 @@ protected:
|
||||
void changeState(const ChangeStateCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
void redirectToken(const TokenCommand &command);
|
||||
|
||||
private slots:
|
||||
|
@@ -74,6 +74,7 @@
|
||||
#include "createscenecommand.h"
|
||||
#include "changenodesourcecommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
@@ -343,6 +344,10 @@ void NodeInstanceServer::token(const TokenCommand &/*command*/)
|
||||
|
||||
}
|
||||
|
||||
void NodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &/*command*/)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &containerVector)
|
||||
{
|
||||
foreach (const AddImportContainer &container, containerVector) {
|
||||
@@ -1056,7 +1061,7 @@ PixmapChangedCommand NodeInstanceServer::createPixmapChangedCommand(const QList<
|
||||
|
||||
foreach (const ServerNodeInstance &instance, instanceList) {
|
||||
if (instance.isValid() && instance.hasContent())
|
||||
imageVector.append(ImageContainer(instance.instanceId(), instance.renderImage()));
|
||||
imageVector.append(ImageContainer(instance.instanceId(), instance.renderImage(), instance.instanceId()));
|
||||
}
|
||||
|
||||
return PixmapChangedCommand(imageVector);
|
||||
|
@@ -91,6 +91,7 @@ public:
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command);
|
||||
void token(const TokenCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
ServerNodeInstance instanceForId(qint32 id) const;
|
||||
bool hasInstanceForId(qint32 id) const;
|
||||
|
@@ -42,6 +42,7 @@ class ChildrenChangedCommand;
|
||||
class StatePreviewImageChangedCommand;
|
||||
class ComponentCompletedCommand;
|
||||
class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
|
||||
class NodeInstanceClientInterface
|
||||
{
|
||||
|
@@ -60,6 +60,7 @@
|
||||
#include "componentcompletedcommand.h"
|
||||
#include "synchronizecommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -171,6 +172,9 @@ void NodeInstanceServerInterface::registerCommands()
|
||||
|
||||
qRegisterMetaType<TokenCommand>("TokenCommand");
|
||||
qRegisterMetaTypeStreamOperators<TokenCommand>("TokenCommand");
|
||||
|
||||
qRegisterMetaType<RemoveSharedMemoryCommand>("RemoveSharedMemoryCommand");
|
||||
qRegisterMetaTypeStreamOperators<RemoveSharedMemoryCommand>("RemoveSharedMemoryCommand");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ class ChangeStateCommand;
|
||||
class CompleteComponentCommand;
|
||||
class ChangeNodeSourceCommand;
|
||||
class TokenCommand;
|
||||
class RemoveSharedMemoryCommand;
|
||||
|
||||
class NodeInstanceServerInterface : public QObject
|
||||
{
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
virtual void completeComponent(const CompleteComponentCommand &command) = 0;
|
||||
virtual void changeNodeSource(const ChangeNodeSourceCommand &command) = 0;
|
||||
virtual void token(const TokenCommand &command) = 0;
|
||||
virtual void removeSharedMemory(const RemoveSharedMemoryCommand &command) = 0;
|
||||
|
||||
static void registerCommands();
|
||||
};
|
||||
|
@@ -256,4 +256,10 @@ void Qt5InformationNodeInstanceServer::completeComponent(const CompleteComponent
|
||||
nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
|
||||
}
|
||||
|
||||
void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Values")
|
||||
ValuesChangedCommand::removeSharedMemorys(command.keyNumbers());
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -47,6 +47,7 @@ public:
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void token(const TokenCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
protected:
|
||||
void collectItemChangesAndSendChangeCommands();
|
||||
|
@@ -115,4 +115,10 @@ QImage Qt5PreviewNodeInstanceServer::renderPreviewImage()
|
||||
return previewImage;
|
||||
}
|
||||
|
||||
void QmlDesigner::Qt5PreviewNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Image")
|
||||
ImageContainer::removeSharedMemory(command.keyNumber());
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void changeState(const ChangeStateCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
QImage renderPreviewImage();
|
||||
|
||||
|
@@ -145,4 +145,10 @@ void Qt5RenderNodeInstanceServer::completeComponent(const CompleteComponentComma
|
||||
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList));
|
||||
}
|
||||
|
||||
void QmlDesigner::Qt5RenderNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Image")
|
||||
ImageContainer::removeSharedMemory(command.keyNumber());
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -44,6 +44,7 @@ public:
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void clearScene(const ClearSceneCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
protected:
|
||||
void collectItemChangesAndSendChangeCommands();
|
||||
|
@@ -74,8 +74,7 @@
|
||||
#include "componentcompletedcommand.h"
|
||||
#include "createscenecommand.h"
|
||||
#include "tokencommand.h"
|
||||
|
||||
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -99,6 +98,12 @@ void Qt4InformationNodeInstanceServer::token(const TokenCommand &command)
|
||||
startRenderTimer();
|
||||
}
|
||||
|
||||
void Qt4InformationNodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Values")
|
||||
ValuesChangedCommand::removeSharedMemorys(command.keyNumbers());
|
||||
}
|
||||
|
||||
void Qt4InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands()
|
||||
{
|
||||
static bool inFunction = false;
|
||||
|
@@ -47,6 +47,7 @@ public:
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void token(const TokenCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
protected:
|
||||
void collectItemChangesAndSendChangeCommands();
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "nodeinstanceclientinterface.h"
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
#include "createscenecommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QDeclarativeView>
|
||||
@@ -70,11 +71,11 @@ void Qt4PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands()
|
||||
if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) {
|
||||
inFunction = true;
|
||||
QVector<ImageContainer> imageContainerVector;
|
||||
imageContainerVector.append(ImageContainer(0, renderPreviewImage()));
|
||||
imageContainerVector.append(ImageContainer(0, renderPreviewImage(), -1));
|
||||
|
||||
foreach (ServerNodeInstance instance, rootNodeInstance().stateInstances()) {
|
||||
instance.activateState();
|
||||
imageContainerVector.append(ImageContainer(instance.instanceId(), renderPreviewImage()));
|
||||
imageContainerVector.append(ImageContainer(instance.instanceId(), renderPreviewImage(), instance.instanceId()));
|
||||
instance.deactivateState();
|
||||
}
|
||||
|
||||
@@ -90,6 +91,12 @@ void Qt4PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*comma
|
||||
|
||||
}
|
||||
|
||||
void Qt4PreviewNodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Image")
|
||||
ImageContainer::removeSharedMemorys(command.keyNumbers());
|
||||
}
|
||||
|
||||
QImage Qt4PreviewNodeInstanceServer::renderPreviewImage()
|
||||
{
|
||||
QSize size = rootNodeInstance().boundingRect().size().toSize();
|
||||
|
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void changeState(const ChangeStateCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
QImage renderPreviewImage();
|
||||
|
||||
|
@@ -73,6 +73,7 @@
|
||||
#include "completecomponentcommand.h"
|
||||
#include "componentcompletedcommand.h"
|
||||
#include "createscenecommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include "dummycontextobject.h"
|
||||
|
||||
@@ -194,4 +195,10 @@ void Qt4RenderNodeInstanceServer::changeState(const ChangeStateCommand &command)
|
||||
QGraphicsItemPrivate::get(item)->notifyBoundingRectChanged = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Qt4RenderNodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
if (command.typeName() == "Image")
|
||||
ImageContainer::removeSharedMemorys(command.keyNumbers());
|
||||
}
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -45,6 +45,7 @@ public:
|
||||
void clearScene(const ClearSceneCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void changeState(const ChangeStateCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
protected:
|
||||
void collectItemChangesAndSendChangeCommands();
|
||||
|
@@ -184,6 +184,8 @@ private: // functions
|
||||
RemoveInstancesCommand createRemoveInstancesCommand(const QList<ModelNode> &nodeList) const;
|
||||
RemoveInstancesCommand createRemoveInstancesCommand(const ModelNode &node) const;
|
||||
RemovePropertiesCommand createRemovePropertiesCommand(const QList<AbstractProperty> &propertyList) const;
|
||||
RemoveSharedMemoryCommand createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, quint32 keyNumber);
|
||||
RemoveSharedMemoryCommand createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, const QList<ModelNode> &nodeList);
|
||||
|
||||
void resetHorizontalAnchors(const ModelNode &node);
|
||||
void resetVerticalAnchors(const ModelNode &node);
|
||||
|
@@ -64,6 +64,7 @@
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
#include "componentcompletedcommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include "synchronizecommand.h"
|
||||
|
||||
@@ -233,13 +234,13 @@ NodeInstanceServerProxy::~NodeInstanceServerProxy()
|
||||
|
||||
|
||||
if (m_qmlPuppetEditorProcess)
|
||||
m_qmlPuppetEditorProcess->kill();
|
||||
m_qmlPuppetEditorProcess->terminate();
|
||||
|
||||
if (m_qmlPuppetPreviewProcess)
|
||||
m_qmlPuppetPreviewProcess->kill();
|
||||
m_qmlPuppetPreviewProcess->terminate();
|
||||
|
||||
if (m_qmlPuppetRenderProcess)
|
||||
m_qmlPuppetRenderProcess->kill();
|
||||
m_qmlPuppetRenderProcess->terminate();
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::dispatchCommand(const QVariant &command)
|
||||
@@ -532,4 +533,9 @@ void NodeInstanceServerProxy::token(const TokenCommand &command)
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -70,6 +70,7 @@ public:
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command);
|
||||
void token(const TokenCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
|
||||
protected:
|
||||
void writeCommand(const QVariant &command);
|
||||
|
@@ -34,7 +34,6 @@
|
||||
#include <QDeclarativeContext>
|
||||
#include <private/qdeclarativeengine_p.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
@@ -79,6 +78,7 @@
|
||||
#include "completecomponentcommand.h"
|
||||
#include "componentcompletedcommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
|
||||
#include "nodeinstanceserverproxy.h"
|
||||
|
||||
@@ -242,6 +242,7 @@ void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
|
||||
void NodeInstanceView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
{
|
||||
nodeInstanceServer()->removeInstances(createRemoveInstancesCommand(removedNode));
|
||||
nodeInstanceServer()->removeSharedMemory(createRemoveSharedMemoryCommand("Image", removedNode.internalId()));
|
||||
removeInstanceAndSubInstances(removedNode);
|
||||
}
|
||||
|
||||
@@ -313,6 +314,7 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList<AbstractProperty>&
|
||||
}
|
||||
|
||||
nodeInstanceServer()->removeInstances(createRemoveInstancesCommand(nodeList));
|
||||
nodeInstanceServer()->removeSharedMemory(createRemoveSharedMemoryCommand("Image", nodeList));
|
||||
nodeInstanceServer()->removeProperties(createRemovePropertiesCommand(nonNodePropertyList));
|
||||
|
||||
foreach (const AbstractProperty &property, propertyList) {
|
||||
@@ -1035,6 +1037,21 @@ RemovePropertiesCommand NodeInstanceView::createRemovePropertiesCommand(const QL
|
||||
return RemovePropertiesCommand(containerList);
|
||||
}
|
||||
|
||||
RemoveSharedMemoryCommand NodeInstanceView::createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, quint32 keyNumber)
|
||||
{
|
||||
return RemoveSharedMemoryCommand(sharedMemoryTypeName, QVector<qint32>() << keyNumber);
|
||||
}
|
||||
|
||||
RemoveSharedMemoryCommand NodeInstanceView::createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, const QList<ModelNode> &nodeList)
|
||||
{
|
||||
QVector<qint32> keyNumberVector;
|
||||
|
||||
foreach (const ModelNode &modelNode, nodeList)
|
||||
keyNumberVector.append(modelNode.internalId());
|
||||
|
||||
return RemoveSharedMemoryCommand(sharedMemoryTypeName, keyNumberVector);
|
||||
}
|
||||
|
||||
void NodeInstanceView::valuesChanged(const ValuesChangedCommand &command)
|
||||
{
|
||||
if (!model())
|
||||
@@ -1052,6 +1069,8 @@ void NodeInstanceView::valuesChanged(const ValuesChangedCommand &command)
|
||||
}
|
||||
}
|
||||
|
||||
nodeInstanceServer()->removeSharedMemory(createRemoveSharedMemoryCommand(QLatin1String("Values"), command.keyNumber()));
|
||||
|
||||
if (!valuePropertyChangeList.isEmpty())
|
||||
emitInstancePropertyChange(valuePropertyChangeList);
|
||||
}
|
||||
@@ -1130,7 +1149,7 @@ void NodeInstanceView::statePreviewImagesChanged(const StatePreviewImageChangedC
|
||||
QVector<ModelNode> previewImageChangeVector;
|
||||
|
||||
foreach (const ImageContainer &container, command.previews()) {
|
||||
if (container.instanceId() == 0) {
|
||||
if (container.keyNumber() == -1) {
|
||||
m_baseStatePreviewImage = container.image();
|
||||
previewImageChangeVector.append(rootModelNode());
|
||||
} else if (hasInstanceForId(container.instanceId())) {
|
||||
|
Reference in New Issue
Block a user