From 00b0dff93f77bed09687b876777bbf0cb4d6bfff Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Thu, 3 Jan 2013 10:34:38 +0000 Subject: 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 --- .../platforms/qnx/qqnxrasterbackingstore.cpp | 25 ++++++++++++++-------- src/plugins/platforms/qnx/qqnxrasterbackingstore.h | 4 +++- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp index 11babe3aaa..47a72f173b 100644 --- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp @@ -60,8 +60,7 @@ QQnxRasterBackingStore::QQnxRasterBackingStore(QWindow *window) { qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window; - // save platform window associated with widget - m_platformWindow = static_cast(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 ®ion, const if (window) targetWindow = static_cast(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 ®ion, 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 ®ion, 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 ®ion) qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window(); m_hasUnflushedPaintOperations = true; - m_platformWindow->adjustBufferSize(); + platformWindow()->adjustBufferSize(); } void QQnxRasterBackingStore::endPaint(const QRegion ®ion) @@ -186,4 +187,10 @@ void QQnxRasterBackingStore::endPaint(const QRegion ®ion) qRasterBackingStoreDebug() << Q_FUNC_INFO << "w =" << window(); } +QQnxWindow *QQnxRasterBackingStore::platformWindow() const +{ + Q_ASSERT(m_window->handle()); + return static_cast(m_window->handle()); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.h b/src/plugins/platforms/qnx/qqnxrasterbackingstore.h index 8abd81f217..a344ff209d 100644 --- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.h +++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.h @@ -72,7 +72,9 @@ private: int dy; }; - QQnxWindow *m_platformWindow; + QQnxWindow *platformWindow() const; + + QWindow *m_window; QList m_scrollOpList; bool m_hasUnflushedPaintOperations; }; -- cgit v1.2.3