Commit 505c90db authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner.NodeInstances: Improve shared memory for pixmap container



Change-Id: I69e815d9f08404931823d9ae5abd0919bd4206b3
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent af0fbc22
......@@ -62,7 +62,7 @@ static QSharedMemory *createSharedMemory(qint32 key, int byteCount)
{
QSharedMemory *sharedMemory = globalSharedMemoryCache.take(key);
if (sharedMemory == 0)
sharedMemory = new QSharedMemory(QString::number(key));
sharedMemory = new QSharedMemory(QString("Image-%1").arg(key));
if (sharedMemory->isAttached())
sharedMemory->detach();
......@@ -94,7 +94,9 @@ QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
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());
}
......@@ -105,11 +107,13 @@ QDataStream &operator<<(QDataStream &out, const ImageContainer &container)
void readSharedMemory(qint32 key, QImage *image, qint32 byteSize)
{
QSharedMemory sharedMemory(QString::number(key));
QSharedMemory sharedMemory(QString("Image-%1").arg(key));
bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly);
if (canAttach)
{
sharedMemory.lock();
qMemCopy(image->bits(), sharedMemory.constData(), byteSize);
sharedMemory.unlock();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment