Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27825

font gdi leak in QWindowsFontEngine

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.0.0 RC 1
    • 5.0.0 Beta 1
    • GUI: Font handling
    • None
    • Windows
    • cbf476242608a575595651a2eb8c40588a4631a4

    Description

      A windows font GDI handle can be leaked in QWindowsFontEngine::alphaMapForGlyph. This is causing steady leak in our application. It is caused by an early function return in the code without cleanup.

      BUG FOUND IN: qtbase/src/plugins/platforms/windows/qwindowsfontengine.cpp (line 1170)
      CODE:

      HFONT font = hfont;
          if (m_fontEngineData->clearTypeEnabled) {
              LOGFONT lf = m_logfont;
              lf.lfQuality = ANTIALIASED_QUALITY;
              font = CreateFontIndirect(&lf);
          }
          QImage::Format mask_format = QWindowsNativeImage::systemFormat();
          mask_format = QImage::Format_RGB32;
      
          QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
          if (mask == 0)
              return QImage();
      ...
      

      POSSIBLE CLEANUP SOLUTION:

      HFONT font = hfont;
      	bool createdFont = false;
          if (m_fontEngineData->clearTypeEnabled) {
              LOGFONT lf = m_logfont;
              lf.lfQuality = ANTIALIASED_QUALITY;
              font = CreateFontIndirect(&lf);
      		createdFont = true;
          }
          QImage::Format mask_format = QWindowsNativeImage::systemFormat();
          mask_format = QImage::Format_RGB32;
      
          QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
          if (mask == 0){
      		if(createdFont){
      			DeleteObject(font);
      		}
              return QImage();
          }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            e0348803 Miikka Heikkinen
            rmcalister Ryan McAlister
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes