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 <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Gabriel de Dietrich 2016-04-27 13:18:41 -07:00 committed by Gabriel de Dietrich
parent 939b7bfe66
commit e6c0373421

View File

@ -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.