QNX: Move buffer count check to appropriate location

The buffer count check should take place right after buffers are created. For
some reason, the buffer count value inside libscreen may become incosistent during
the course of the program.

Change-Id: Icbbaf4734eac5b0c5c95bdd93771899f9fcdb7db
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
Rafael Roquetto 2012-11-29 16:42:11 -02:00 committed by The Qt Project
parent 3492a80959
commit 1b95d3331c

View File

@ -358,6 +358,19 @@ void QQnxWindow::setBufferSize(const QSize &size)
if (result != 0) {
qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno);
}
// check if there are any buffers available
int bufferCount = 0;
result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);
if (result != 0) {
qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno);
}
if (bufferCount != MAX_BUFFER_COUNT) {
qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d. You might experience problems.",
MAX_BUFFER_COUNT, bufferCount);
}
}
// Cache new buffer size
@ -378,22 +391,10 @@ QQnxBuffer &QQnxWindow::renderBuffer()
// Check if render buffer is invalid
if (m_currentBufferIndex == -1) {
// check if there are any buffers available
int bufferCount = 0;
int result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);
if (result != 0) {
qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno);
}
if (bufferCount != MAX_BUFFER_COUNT) {
qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d", MAX_BUFFER_COUNT, bufferCount);
}
// Get all buffers available for rendering
errno = 0;
screen_buffer_t buffers[MAX_BUFFER_COUNT];
result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
const int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
if (result != 0) {
qFatal("QQnxWindow: failed to query window buffers, errno=%d", errno);
}