forked from qt-creator/qt-creator
QmlDesigner.NodeInstance: Add environment variable to disable shared memory
Change-Id: I4146186d57322e8dd06b5c3baf538c98119ff201 Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
This commit is contained in:
@@ -90,7 +90,9 @@ static QSharedMemory *createSharedMemory(qint32 key, int byteCount)
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
|
||||
{
|
||||
if (command.valueChanges().count() > 5) {
|
||||
static const bool dontUseSharedMemory = !qgetenv("DESIGNER_DONT_USE_SHARED_MEMORY").isEmpty();
|
||||
|
||||
if (!dontUseSharedMemory && command.valueChanges().count() > 5) {
|
||||
static quint32 keyCounter = 0;
|
||||
++keyCounter;
|
||||
command.m_keyNumber = keyCounter;
|
||||
|
||||
@@ -143,19 +143,26 @@ static void writeStream(QDataStream &out, const QImage &image)
|
||||
QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
|
||||
{
|
||||
const int extraDataSize = 20;
|
||||
static const bool dontUseSharedMemory = !qgetenv("DESIGNER_DONT_USE_SHARED_MEMORY").isEmpty();
|
||||
|
||||
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)
|
||||
writeSharedMemory(sharedMemory, image);
|
||||
else
|
||||
if (dontUseSharedMemory) {
|
||||
out << qint32(0);
|
||||
writeStream(out, image);
|
||||
} else {
|
||||
QSharedMemory *sharedMemory = createSharedMemory(container.keyNumber(), image.byteCount() + extraDataSize);
|
||||
|
||||
out << qint32(sharedMemory != 0); // send if shared memory is used
|
||||
|
||||
if (sharedMemory)
|
||||
writeSharedMemory(sharedMemory, image);
|
||||
else
|
||||
writeStream(out, image);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user