From e6c0373421a3239a828969d5c49e5418b1122dd0 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 27 Apr 2016 13:18:41 -0700 Subject: Cocoa: Clear the backing store pointer when changing window If the geometry is being changed at some point while showing the widget after reparenting, we set the Cocoa frame on the QNSView. This results in Cocoa invalidating the view and calling drawRect: before we get a chance to flush the backing store. This may be an issue if the previous parent toplevel window has been deleted. In that case, the backing store pointer is a dangling one, resulting in a crash. Change-Id: I18b5dd7794a3bde8815daf3f84e4113a37aaea90 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4b7b50a265..34c37d8aed 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -284,6 +284,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewDidMoveToWindow { + m_backingStore = Q_NULLPTR; m_isMenuView = [self.window.className isEqualToString:@"NSCarbonMenuWindow"]; if (self.window) { // This is the case of QWidgetAction's generated QWidget inserted in an NSMenu. -- cgit v1.2.3