From d04207342ea4d22e42257eb0adc1048fd2e068b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Oct 2016 13:33:00 +0200 Subject: macOS: Fix crash in QCocoaBackingStore::format() after closing window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closing a window results in sending an expose event to obscure the window, which gets delivered after the corresponding QPlatformWindow has been destroyed. If the client application (wrongly) tries to render as a result of this expose event, using the existing QBackingStore, it will potentially result in a resize of the backing store, for example if the global device pixel ratio is different from what the window had when it still had a QPlatformWindow. The resize in turn requires the format() of the window, but since we no longer have a QPlatformWindow we can't base the format on that. Change-Id: Ied6a3a745f20087c2287ad86e1c66808467b6183 Reviewed-by: Erik Verbruggen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index a74995319b..1d7ad772dc 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -57,7 +57,8 @@ QCocoaBackingStore::~QCocoaBackingStore() QImage::Format QCocoaBackingStore::format() const { - if (static_cast(window()->handle())->m_drawContentBorderGradient) + QCocoaWindow *cocoaWindow = static_cast(window()->handle()); + if (cocoaWindow && cocoaWindow->m_drawContentBorderGradient) return QImage::Format_ARGB32_Premultiplied; return QRasterBackingStore::format(); -- cgit v1.2.3