diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-02-02 16:30:43 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-02-03 15:42:57 (GMT) |
commit | 68f78ba6be29b839433d924b5dc348d6d94b3d43 (patch) | |
tree | 0433de27e11ceaea37e4fc8ce8a9be2a84950716 /src/gui | |
parent | 2fc0d4ca43afb4072e92fd15648285c2c26d9da1 (diff) | |
download | Qt-68f78ba6be29b839433d924b5dc348d6d94b3d43.zip Qt-68f78ba6be29b839433d924b5dc348d6d94b3d43.tar.gz Qt-68f78ba6be29b839433d924b5dc348d6d94b3d43.tar.bz2 |
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')
-rw-r--r-- | src/gui/image/qnativeimage.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 01baa36..8face87 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) { |