Handle failed SHM attach in XCB backing store.
Change-Id: I5f97c0c6030d13b68cfc17d19ba969cd78f79c3f Reviewed-on: http://codereview.qt.nokia.com/1943 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
This commit is contained in:
parent
7b3b6b5afa
commit
e026f767c9
@ -114,12 +114,18 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
|
|||||||
|
|
||||||
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
|
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
|
||||||
if (error) {
|
if (error) {
|
||||||
qWarning() << "QXcbBackingStore: Unable to attach to shared memory segment";
|
|
||||||
free(error);
|
free(error);
|
||||||
}
|
|
||||||
|
|
||||||
if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1)
|
shmdt(m_shm_info.shmaddr);
|
||||||
qWarning() << "QXcbBackingStore: Error while marking the shared memory segment to be destroyed";
|
shmctl(m_shm_info.shmid, IPC_RMID, 0);
|
||||||
|
|
||||||
|
m_shm_info.shmaddr = 0;
|
||||||
|
|
||||||
|
m_xcb_image->data = (uint8_t *)qMalloc(segmentSize);
|
||||||
|
} else {
|
||||||
|
if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1)
|
||||||
|
qWarning() << "QXcbBackingStore: Error while marking the shared memory segment to be destroyed";
|
||||||
|
}
|
||||||
|
|
||||||
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
|
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
|
||||||
}
|
}
|
||||||
@ -127,14 +133,18 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
|
|||||||
void QXcbShmImage::destroy()
|
void QXcbShmImage::destroy()
|
||||||
{
|
{
|
||||||
const int segmentSize = m_xcb_image ? (m_xcb_image->stride * m_xcb_image->height) : 0;
|
const int segmentSize = m_xcb_image ? (m_xcb_image->stride * m_xcb_image->height) : 0;
|
||||||
if (segmentSize)
|
if (segmentSize && m_shm_info.shmaddr)
|
||||||
Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg));
|
Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg));
|
||||||
|
|
||||||
xcb_image_destroy(m_xcb_image);
|
xcb_image_destroy(m_xcb_image);
|
||||||
|
|
||||||
if (segmentSize) {
|
if (segmentSize) {
|
||||||
shmdt(m_shm_info.shmaddr);
|
if (m_shm_info.shmaddr) {
|
||||||
shmctl(m_shm_info.shmid, IPC_RMID, 0);
|
shmdt(m_shm_info.shmaddr);
|
||||||
|
shmctl(m_shm_info.shmid, IPC_RMID, 0);
|
||||||
|
} else {
|
||||||
|
qFree(m_xcb_image->data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_gc)
|
if (m_gc)
|
||||||
@ -155,18 +165,32 @@ void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &s
|
|||||||
}
|
}
|
||||||
|
|
||||||
Q_XCB_NOOP(connection());
|
Q_XCB_NOOP(connection());
|
||||||
xcb_image_shm_put(xcb_connection(),
|
if (m_shm_info.shmaddr) {
|
||||||
|
xcb_image_shm_put(xcb_connection(),
|
||||||
|
window,
|
||||||
|
m_gc,
|
||||||
|
m_xcb_image,
|
||||||
|
m_shm_info,
|
||||||
|
source.x(),
|
||||||
|
source.y(),
|
||||||
|
target.x(),
|
||||||
|
target.y(),
|
||||||
|
source.width(),
|
||||||
|
source.height(),
|
||||||
|
false);
|
||||||
|
} else {
|
||||||
|
xcb_image_t *subimage = xcb_image_subimage(m_xcb_image, source.x(), source.y(), source.width(), source.height(),
|
||||||
|
0, 0, 0);
|
||||||
|
xcb_image_put(xcb_connection(),
|
||||||
window,
|
window,
|
||||||
m_gc,
|
m_gc,
|
||||||
m_xcb_image,
|
subimage,
|
||||||
m_shm_info,
|
|
||||||
source.x(),
|
|
||||||
source.y(),
|
|
||||||
target.x(),
|
target.x(),
|
||||||
target.y(),
|
target.y(),
|
||||||
source.width(),
|
0);
|
||||||
source.height(),
|
|
||||||
false);
|
xcb_image_destroy(subimage);
|
||||||
|
}
|
||||||
Q_XCB_NOOP(connection());
|
Q_XCB_NOOP(connection());
|
||||||
|
|
||||||
m_dirty = m_dirty | source;
|
m_dirty = m_dirty | source;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user