Hi guys!       
      
      Here is the description of CR:       
      http://bugs.sun.com/view_bug.do?bug_id=7082294       
      
      Patch with changes attached.       
      
      Description of the fix:       
      Sometimes execution of AwtObjectList::Cleanup() could be delayed       by       
      posting WM_AWT_OBJECTLISTCLEANUP message.       
        From the other side this method is called from       AwtToolkit::Dispose().       
      There AwtObjectList::Cleanup() is followed by AwtFont::Cleanup().       
      Thus, sometimes we could have the situation when       AwtFont::Cleanup() is       
      called before the main functionality of AwtObjectList::Cleanup().       
      It means that all HFONT objects would be deleted from       AwtFontCache.       
      So when AwtFont::Dispose() would be called from       AwtObjectList::Cleanup()       
      it would not find HFONT in AwtFontCache and would try to delete       HFONT       
      (that is deleted in AwtFontCache) once again.       
      There is also a custom message pump in AwtToolkit::Dispose() that       allows       
      posted WM_AWT_OBJECTLISTCLEANUP be handled.       
      If we move AwtFont::Cleanup() right after that message pump we       guarantee       
      that AwtObjectList::Cleanup() would always be called before       
      AwtFont::Cleanup().       
      That what my fix is about.       
      
      PS: I also left my changes in AwtFont to emilinate invalid HFONT       usage       
      and access violation probability between AwtFont::Dispose() and       
      AwtFont::~AwtFont() calls.       
      
      PPS: This implementation is a kind of workaround for 7u4. As for       JDK 8 - font caching should be improved.       
      
      Thanks,       
      Oleg.       
        ">

(original) (raw)

Hi guys!

Here is the description of CR:
http://bugs.sun.com/view\_bug.do?bug\_id=7082294

Patch with changes attached.

Description of the fix:
Sometimes execution of AwtObjectList::Cleanup() could be delayed by
posting WM\_AWT\_OBJECTLISTCLEANUP message.
From the other side this method is called from AwtToolkit::Dispose().
There AwtObjectList::Cleanup() is followed by AwtFont::Cleanup().
Thus, sometimes we could have the situation when AwtFont::Cleanup() is
called before the main functionality of AwtObjectList::Cleanup().
It means that all HFONT objects would be deleted from AwtFontCache.
So when AwtFont::Dispose() would be called from AwtObjectList::Cleanup()
it would not find HFONT in AwtFontCache and would try to delete HFONT
(that is deleted in AwtFontCache) once again.
There is also a custom message pump in AwtToolkit::Dispose() that allows
posted WM\_AWT\_OBJECTLISTCLEANUP be handled.
If we move AwtFont::Cleanup() right after that message pump we guarantee
that AwtObjectList::Cleanup() would always be called before
AwtFont::Cleanup().
That what my fix is about.

PS: I also left my changes in AwtFont to emilinate invalid HFONT usage
and access violation probability between AwtFont::Dispose() and
AwtFont::\~AwtFont() calls.

PPS: This implementation is a kind of workaround for 7u4\. As for JDK 8 - font caching should be improved.

Thanks,
Oleg.