mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames
Fix memory management Reviewed-by: art, serb
This commit is contained in:
parent
7572cbd5aa
commit
09dd368c9b
2 changed files with 26 additions and 2 deletions
|
@ -63,6 +63,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||||
private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
|
private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
|
||||||
private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
|
private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
|
||||||
private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr);
|
private static native void nativeSynthesizeMouseEnteredExitedEvents(long nsWindowPtr);
|
||||||
|
private static native void nativeDispose(long nsWindowPtr);
|
||||||
|
|
||||||
private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr);
|
private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr);
|
||||||
|
|
||||||
|
@ -423,6 +424,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||||
EventQueue.invokeLater(new Runnable() {
|
EventQueue.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
contentView.dispose();
|
contentView.dispose();
|
||||||
|
nativeDispose(getNSWindowPtr());
|
||||||
CPlatformWindow.super.dispose();
|
CPlatformWindow.super.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -228,6 +228,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.nsWindow == nil) return nil; // no hope either
|
if (self.nsWindow == nil) return nil; // no hope either
|
||||||
|
[self.nsWindow release]; // the property retains the object already
|
||||||
|
|
||||||
self.isEnabled = YES;
|
self.isEnabled = YES;
|
||||||
self.javaPlatformWindow = platformWindow;
|
self.javaPlatformWindow = platformWindow;
|
||||||
|
@ -677,9 +678,9 @@ AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||||
styleBits:styleBits
|
styleBits:styleBits
|
||||||
frameRect:frameRect
|
frameRect:frameRect
|
||||||
contentView:contentView];
|
contentView:contentView];
|
||||||
|
// the window is released is CPlatformWindow.nativeDispose()
|
||||||
|
|
||||||
if (window) CFRetain(window);
|
if (window) CFRetain(window.nsWindow);
|
||||||
[window release]; // GC
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
JNF_COCOA_EXIT(env);
|
JNF_COCOA_EXIT(env);
|
||||||
|
@ -1160,3 +1161,24 @@ JNF_COCOA_ENTER(env);
|
||||||
JNF_COCOA_EXIT(env);
|
JNF_COCOA_EXIT(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose
|
||||||
|
(JNIEnv *env, jclass clazz, jlong windowPtr)
|
||||||
|
{
|
||||||
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
|
NSWindow *nsWindow = OBJC(windowPtr);
|
||||||
|
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
|
||||||
|
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
||||||
|
|
||||||
|
// AWTWindow holds a reference to the NSWindow in its nsWindow
|
||||||
|
// property. Unsetting the delegate allows it to be deallocated
|
||||||
|
// which releases the reference. This, in turn, allows the window
|
||||||
|
// itself be deallocated.
|
||||||
|
[nsWindow setDelegate: nil];
|
||||||
|
|
||||||
|
[window release];
|
||||||
|
}];
|
||||||
|
|
||||||
|
JNF_COCOA_EXIT(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue