QNX: Don't crash because the window hasn't been initialized yet.

Don't call window->handle() inside the backingstore ctor, because
we might still have the window ctor in the call stack
( ex: a QWindow sub-class that creates a backingstore inside it's
ctor).

Crash can be reproduced by running examples/gui/analogclock.

Change-Id: I4622ceaeb05696c5ae0181a528f58e5d102dcb22
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Sergio Martins 2013-01-03 10:34:38 +00:00 committed by The Qt Project
parent 8e3d4f5e87
commit 00b0dff93f
2 changed files with 19 additions and 10 deletions

View File

@ -60,8 +60,7 @@ QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window)
{
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window;
// save platform window associated with widget
m_platformWindow = static_cast<QQnxWindow*>(window->handle());
m_window = window;
}
QQnxRasterBackingStore::~QQnxRasterBackingStore()
@ -71,8 +70,9 @@ QQnxRasterBackingStore::~QQnxRasterBackingStore()
QPaintDevice *QQnxRasterBackingStore::paintDevice()
{
if (m_platformWindow->hasBuffers())
return m_platformWindow->renderBuffer().image();
QQnxWindow *platformWindow = this->platformWindow();
if (platformWindow->hasBuffers())
return platformWindow->renderBuffer().image();
return 0;
}
@ -85,7 +85,8 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const
if (window)
targetWindow = static_cast<QQnxWindow *>(window->handle());
if (!targetWindow || targetWindow == m_platformWindow) {
QQnxWindow *platformWindow = this->platformWindow();
if (!targetWindow || targetWindow == platformWindow) {
// visit all pending scroll operations
for (int i = m_scrollOpList.size() - 1; i >= 0; i--) {
@ -93,14 +94,14 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const
// do the scroll operation
ScrollOp &op = m_scrollOpList[i];
QRegion srcArea = op.totalArea.intersected( op.totalArea.translated(-op.dx, -op.dy) );
m_platformWindow->scroll(srcArea, op.dx, op.dy);
platformWindow->scroll(srcArea, op.dx, op.dy);
}
// clear all pending scroll operations
m_scrollOpList.clear();
// update the display with newly rendered content
m_platformWindow->post(region);
platformWindow->post(region);
} else if (targetWindow) {
// The contents of the backing store should be flushed to a different window than the
@ -119,7 +120,7 @@ void QQnxRasterBackingStore::flush(QWindow *window, const QRegion &region, const
Q_ASSERT(!m_hasUnflushedPaintOperations);
targetWindow->adjustBufferSize();
targetWindow->blitFrom(m_platformWindow, offset, region);
targetWindow->blitFrom(platformWindow, offset, region);
targetWindow->post(region);
} else {
@ -177,7 +178,7 @@ void QQnxRasterBackingStore::beginPaint(const QRegion &region)
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
m_hasUnflushedPaintOperations = true;
m_platformWindow->adjustBufferSize();
platformWindow()->adjustBufferSize();
}
void QQnxRasterBackingStore::endPaint(const QRegion &region)
@ -186,4 +187,10 @@ void QQnxRasterBackingStore::endPaint(const QRegion &region)
qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window();
}
QQnxWindow *QQnxRasterBackingStore::platformWindow() const
{
Q_ASSERT(m_window->handle());
return static_cast<QQnxWindow*>(m_window->handle());
}
QT_END_NAMESPACE

View File

@ -72,7 +72,9 @@ private:
int dy;
};
QQnxWindow *m_platformWindow;
QQnxWindow *platformWindow() const;
QWindow *m_window;
QList<ScrollOp> m_scrollOpList;
bool m_hasUnflushedPaintOperations;
};