diff options
author | Morten Johan Sorvig <morten.sorvig@nokia.com> | 2012-04-20 08:29:14 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-20 12:46:47 +0200 |
commit | fb8cd418fbda05b2aff3f0f7035df3ef8343007d (patch) | |
tree | 5bc56e181da64c9183ec17e8bdb7e455c0b8c694 /src/plugins/platforms/cocoa/qcocoabackingstore.mm | |
parent | 65ae2151c34877d7a5a046a39e34a8513c849f8f (diff) |
Fix crash in QCocoaBackingStore.
QWindow->handle() may be null during construction,
and also during calls to resize(). Get and check
the pointer at each call instead of caching it
in the constructor.
Change-Id: Icd950b55e16fdd2077e3b7fe3c3393d8b89b5903
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoabackingstore.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoabackingstore.mm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index f0ff7ba0d6..660c2b651f 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE QCocoaBackingStore::QCocoaBackingStore(QWindow *window) : QPlatformBackingStore(window) { - m_cocoaWindow = static_cast<QCocoaWindow *>(window->handle()); m_image = new QImage(window->geometry().size(),QImage::Format_ARGB32_Premultiplied); } @@ -72,14 +71,19 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion ®ion, const QPo QRect geo = region.boundingRect(); NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height()); - [m_cocoaWindow->m_contentView displayRect:rect]; + QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); + if (cocoaWindow) + [cocoaWindow->m_contentView displayRect:rect]; } void QCocoaBackingStore::resize(const QSize &size, const QRegion &) { delete m_image; m_image = new QImage(size, QImage::Format_ARGB32_Premultiplied); - [static_cast<QNSView *>(m_cocoaWindow->m_contentView) setImage:m_image]; + + QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window()->handle()); + if (cocoaWindow) + [static_cast<QNSView *>(cocoaWindow->m_contentView) setImage:m_image]; } bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy) |