提交 d3a15c1e 编写于 作者: P pchelko

8041572: [macosx] huge native memory leak in AWTWindow.m

Reviewed-by: serb, anthony
上级 43b8095d
...@@ -261,7 +261,8 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -261,7 +261,8 @@ AWT_ASSERT_APPKIT_THREAD;
// returns id for the topmost window under mouse // returns id for the topmost window under mouse
+ (NSInteger) getTopmostWindowUnderMouseID { + (NSInteger) getTopmostWindowUnderMouseID {
NSInteger result = -1;
NSRect screenRect = [[NSScreen mainScreen] frame]; NSRect screenRect = [[NSScreen mainScreen] frame];
NSPoint nsMouseLocation = [NSEvent mouseLocation]; NSPoint nsMouseLocation = [NSEvent mouseLocation];
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y); CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
...@@ -274,11 +275,13 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -274,11 +275,13 @@ AWT_ASSERT_APPKIT_THREAD;
CGRect rect; CGRect rect;
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect); CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
if (CGRectContainsPoint(rect, cgMouseLocation)) { if (CGRectContainsPoint(rect, cgMouseLocation)) {
return [[window objectForKey:(id)kCGWindowNumber] integerValue]; result = [[window objectForKey:(id)kCGWindowNumber] integerValue];
break;
} }
} }
} }
return -1; [windows release];
return result;
} }
// checks that this window is under the mouse cursor and this point is not overlapped by others windows // checks that this window is under the mouse cursor and this point is not overlapped by others windows
......
...@@ -66,7 +66,8 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){ ...@@ -66,7 +66,8 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
CFArrayAppendValue(validModes, cRef); CFArrayAppendValue(validModes, cRef);
} }
} }
CFRelease(allModes);
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID); CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
BOOL containsCurrentMode = NO; BOOL containsCurrentMode = NO;
...@@ -81,6 +82,7 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){ ...@@ -81,6 +82,7 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
if (!containsCurrentMode) { if (!containsCurrentMode) {
CFArrayAppendValue(validModes, currentMode); CFArrayAppendValue(validModes, currentMode);
} }
CGDisplayModeRelease(currentMode);
return validModes; return validModes;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册