summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qnativeimage.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-02-02 17:30:43 +0100
committerSamuel Rødal <samuel.rodal@nokia.com>2011-02-03 16:42:57 +0100
commit68f78ba6be29b839433d924b5dc348d6d94b3d43 (patch)
tree0433de27e11ceaea37e4fc8ce8a9be2a84950716 /src/gui/image/qnativeimage.cpp
parent2fc0d4ca43afb4072e92fd15648285c2c26d9da1 (diff)
Fixed MIT-SHM errors in QNativeImage.
The POSIX standard doesn't allow attaching to IPC_RMID-flagged memory, even if Linux allows it, thus we need to wait until after calling XShmAttach and XSync before we set the flag. See the man page for shmctl(). Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/gui/image/qnativeimage.cpp')
-rw-r--r--src/gui/image/qnativeimage.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 01baa36016..8face87a92 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -181,15 +181,17 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
if (ok) {
xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
xshminfo.shmaddr = xshmimg->data;
- if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
- qWarning() << "Error while marking the shared memory segment to be destroyed";
ok = (xshminfo.shmaddr != (char*)-1);
if (ok)
image = QImage((uchar *)xshmimg->data, width, height, format);
}
xshminfo.readOnly = false;
- if (ok)
+ if (ok) {
ok = XShmAttach(X11->display, &xshminfo);
+ XSync(X11->display, False);
+ if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
+ qWarning() << "Error while marking the shared memory segment to be destroyed";
+ }
if (!ok) {
qWarning() << "QNativeImage: Unable to attach to shared memory segment.";
if (xshmimg->data) {