diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-01 10:37:30 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-01 11:01:32 +0200 |
commit | 646fcc1bd30ea9513b3d413f21677b2bbf947a4c (patch) | |
tree | 9ed6921a8e136c305242a1460de5647707244c86 /src/plugins/platforms/xcb | |
parent | 38745b341c5c4d49fdb0e87f79f2714f105f63fe (diff) |
Do not choke on zero-sized windows.
Configure requests with zero width or height will always
fail with BadValue and have to be avoided. Same goes for
shm segments of size 0.
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index afcec8e139..d46e1407c7 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -285,7 +285,10 @@ void QXcbWindow::setGeometry(const QRect &rect) QPlatformWindow::setGeometry(rect); const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; - const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() }; + const quint32 values[] = { rect.x(), + rect.y(), + qBound(1, rect.width(), XCOORD_MAX), + qBound(1, rect.height(), XCOORD_MAX) }; Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); } diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index ecfbddbfd4..63378515cc 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -98,7 +98,10 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI ~0, 0); - int segmentSize = m_xcb_image->stride * m_xcb_image->height; + const int segmentSize = m_xcb_image->stride * m_xcb_image->height; + if (!segmentSize) + return; + int id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0777); if (id == -1) qWarning("QXcbShmImage: shmget() failed (%d) for size %d (%dx%d)", @@ -122,10 +125,17 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI void QXcbShmImage::destroy() { - Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg)); + const int segmentSize = m_xcb_image ? (m_xcb_image->stride * m_xcb_image->height) : 0; + if (segmentSize) + Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg)); + xcb_image_destroy(m_xcb_image); - shmdt(m_shm_info.shmaddr); - shmctl(m_shm_info.shmid, IPC_RMID, 0); + + if (segmentSize) { + shmdt(m_shm_info.shmaddr); + shmctl(m_shm_info.shmid, IPC_RMID, 0); + } + if (m_gc) Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); } |