Cocoa: remove current contentView when clearing window
authorTeemu Katajisto <teemu.katajisto@digia.com>
Wed, 10 Oct 2012 13:05:22 +0000 (16:05 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 17 Oct 2012 10:55:49 +0000 (12:55 +0200)
Otherwise they might be still events sent to view with no
proper QWindow. Also, add dealloc QNSView for clean up.

Task-number: QTBUG-26580
Task-number: QTBUG-27456
Change-Id: Icdbe5c39490b72ec82795c2d71e5671cea81921e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/cocoa/qnsview.mm

index 93d566d..b9ad356 100644 (file)
@@ -713,6 +713,7 @@ void QCocoaWindow::setNSWindow(NSWindow *window)
 
 void QCocoaWindow::clearNSWindow(NSWindow *window)
 {
+    [window setContentView:nil];
     [window setDelegate:nil];
     [window clearPlatformWindow];
     [[NSNotificationCenter defaultCenter] removeObserver:m_contentView];
index a953b25..f4ba815 100644 (file)
@@ -89,6 +89,14 @@ static QTouchDevice *touchDevice = 0;
     return self;
 }
 
+- (void)dealloc
+{
+    CGImageRelease(m_cgImage);
+    m_cgImage = 0;
+    m_window = 0;
+    [super dealloc];
+}
+
 - (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow
 {
     self = [self init];