+2007-04-23 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Darin.
+
+ Bug 6658: World leak when closing inspected window
+ http://bugs.webkit.org/show_bug.cgi?id=6658 and <rdar://problem/4411863>
+
+ Removes over-retains of the inspector WebView, WebInspector and WebInspectorPanel.
+
+ * WebInspector/WebInspector.m:
+ (+[WebInspector sharedWebInspector]): Return the global sharedWebInspector variable.
+ (-[WebInspector window]): Release the window after calling setWindow:.
+ (-[WebInspector windowWillClose:]): Set the JavaScript Inspector variable to null and expire the current highlight.
+ Also clear the global sharedWebInspector variable and release it if self equals sharedWebInspector.
+ (-[WebInspector showWindow:]): Set the JavaScript Inspector variable back to self.
+ * WebInspector/WebInspectorInternal.h: Remove the isSharedInspector member variable.
+ * WebView/WebView.mm:
+ (-[WebView windowScriptObject]): Return nil if core([self mainFrame]) is NULL.
+
2007-04-23 Darin Adler <darin@apple.com>
Reviewed by Hyatt.
#pragma mark -
-@implementation WebInspector
+static WebInspector *sharedWebInspector = nil;
+@implementation WebInspector
+ (WebInspector *)sharedWebInspector
{
- static WebInspector *_sharedWebInspector = nil;
- if (!_sharedWebInspector) {
- _sharedWebInspector = [[self alloc] init];
- _sharedWebInspector->_private->isSharedInspector = YES;
- }
-
- return _sharedWebInspector;
+ if (!sharedWebInspector)
+ sharedWebInspector = [[self alloc] init];
+ return sharedWebInspector;
}
#pragma mark -
[window setContentView:_private->webView];
[self setWindow:window];
+ [window release];
+
return window;
}
- (void)windowWillClose:(NSNotification *)notification
{
+ [_private->currentHighlight expire];
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillResignActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:WebNodeHighlightExpiredNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewFrameDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSSystemColorsDidChangeNotification object:nil];
[self setFocusedDOMNode:nil];
[self setWebFrame:nil];
- if (!_private->isSharedInspector)
+ [[_private->webView windowScriptObject] setValue:[NSNull null] forKey:@"Inspector"];
+
+ if (self == sharedWebInspector) {
[self release];
+ sharedWebInspector = nil;
+ }
}
- (IBAction)showWindow:(id)sender
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateSystemColors) name:NSSystemColorsDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive) name:NSApplicationWillResignActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive) name:NSApplicationDidBecomeActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:nil];
+
+ [[_private->webView windowScriptObject] setValue:self forKey:@"Inspector"];
[super showWindow:sender];
}
[(NSPanel *)[self window] setFloatingPanel:YES];
}
+- (void)_applicationWillTerminate
+{
+ [_private->webView close];
+}
+
- (void)_webFrameDetached:(WebFrame *)frame
{
[self setRootDOMNode:nil];