From bf6c304c44d4013fb7093dc05086b4fd3d3c0fed Mon Sep 17 00:00:00 2001 From: Oleg Pekhovskiy Date: Thu, 25 Oct 2012 19:50:30 +0400 Subject: [PATCH] 7082294: nsk/regression/b4265661 crashes on windows Reviewed-by: art, anthony --- jdk/src/windows/native/sun/windows/awt_Font.cpp | 8 +++++--- jdk/src/windows/native/sun/windows/awt_Toolkit.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Font.cpp b/jdk/src/windows/native/sun/windows/awt_Font.cpp index d07cdae0467..185514c1972 100644 --- a/jdk/src/windows/native/sun/windows/awt_Font.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Font.cpp @@ -150,6 +150,7 @@ AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont) AwtFont::~AwtFont() { + delete[] m_hFont; } void AwtFont::Dispose() { @@ -160,11 +161,12 @@ void AwtFont::Dispose() { /* NOTE: delete of windows HFONT happens in FontCache::Remove only when the final reference to the font is disposed */ } else if (font != NULL) { - // if font was not in cache, its not shared and we delete it now - VERIFY(::DeleteObject(font)); + // if font was not in cache, its not shared and we delete it now + DASSERT(::GetObjectType(font) == OBJ_FONT); + VERIFY(::DeleteObject(font)); } + m_hFont[i] = NULL; } - delete[] m_hFont; AwtObject::Dispose(); } diff --git a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp index 913540399b5..e8b2d51931a 100644 --- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp @@ -534,7 +534,6 @@ BOOL AwtToolkit::Dispose() { D3DInitializer::GetInstance().Clean(); AwtObjectList::Cleanup(); - AwtFont::Cleanup(); awt_dnd_uninitialize(); awt_clipboard_uninitialize((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)); @@ -554,6 +553,8 @@ BOOL AwtToolkit::Dispose() { ::DispatchMessage(&msg); } + AwtFont::Cleanup(); + HWND toolkitHWndToDestroy = tk.m_toolkitHWnd; tk.m_toolkitHWnd = 0; VERIFY(::DestroyWindow(toolkitHWndToDestroy) != NULL);