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.
This commit is contained in:
parent
38745b341c
commit
646fcc1bd3
@ -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));
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
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);
|
||||
|
||||
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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user