summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins.qnx@kdab.com>2013-01-03 10:34:38 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-03 18:19:28 +0100
commit00b0dff93f77bed09687b876777bbf0cb4d6bfff (patch)
tree0df0278d49f57b3b2d11596368d4132153064a75 /src/plugins
parent8e3d4f5e8752c035036a00c85b5dccc2676e82da (diff)
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>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp25
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterbackingstore.h4
2 files changed, 19 insertions, 10 deletions
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<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
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<ScrollOp> m_scrollOpList;
bool m_hasUnflushedPaintOperations;
};