summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>2012-10-24 18:03:28 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-30 16:34:28 (GMT)
commit2d487381e8537024bbb10b03d324cea6b6060185 (patch)
tree146b5e2c2db589344416ffaa169c2aacb3570fef /src
parent343f559bc7dd345ff8b03ddc8695bfe124310f6b (diff)
downloadQt-2d487381e8537024bbb10b03d324cea6b6060185.zip
Qt-2d487381e8537024bbb10b03d324cea6b6060185.tar.gz
Qt-2d487381e8537024bbb10b03d324cea6b6060185.tar.bz2
BlackBerry: Query dynamic buffer count at runtime
While unlikely, there are cases in which QBBWindow::renderBuffer() is called before the window buffers have been created. Without this check, the program will abort on QBBBuffer constructor, since the value that will be passed to it will be of an invalid buffer. cherry-picked from qt5 c89dc4fdd2770ba3ad52303a2f4cb0c6403a2ecd Change-Id: I1f1cde76a364480f3bc77eaaa59ca3cfba2eb618 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp5
-rw-r--r--src/plugins/platforms/blackberry/qbbwindow.cpp13
2 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
index 11f2cb6..bab2aca 100644
--- a/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
+++ b/src/plugins/platforms/blackberry/qbbrasterwindowsurface.cpp
@@ -72,7 +72,10 @@ QBBRasterWindowSurface::~QBBRasterWindowSurface()
QPaintDevice *QBBRasterWindowSurface::paintDevice()
{
- return mPlatformWindow->renderBuffer().image();
+ if (mPlatformWindow->hasBuffers())
+ return mPlatformWindow->renderBuffer().image();
+
+ return 0;
}
void QBBRasterWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
diff --git a/src/plugins/platforms/blackberry/qbbwindow.cpp b/src/plugins/platforms/blackberry/qbbwindow.cpp
index 5d6a1c1..650601d 100644
--- a/src/plugins/platforms/blackberry/qbbwindow.cpp
+++ b/src/plugins/platforms/blackberry/qbbwindow.cpp
@@ -338,11 +338,22 @@ QBBBuffer &QBBWindow::renderBuffer()
// check if render buffer is invalid
if (mCurrentBufferIndex == -1) {
+ // check if there are any buffers available
+ int bufferCount = 0;
+ int result = screen_get_window_property_iv(mWindow, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);
+
+ if (result != 0) {
+ qFatal("QBBWindow: failed to query window buffer count, errno=%d", errno);
+ }
+
+ if (bufferCount != MAX_BUFFER_COUNT) {
+ qFatal("QBBWindow: 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];
- int result = screen_get_window_property_pv(mWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
+ result = screen_get_window_property_pv(mWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers);
if (result != 0) {
qFatal("QBBWindow: failed to query window buffers, errno=%d", errno);
}