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

QWindowsPrintDevice::printableMargins() leaks GDI objects (HDC)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0 RC
    • 5.4.0 Alpha
    • GUI: Printing
    • None
    • Qt 5.3.x
      Windows 7 Professional
      Visual Studio 2013
    • 28857e7ad03bb416a1bae20b3771b799dee802c7

    Description

      QWindowsPrintDevice::printableMargins allocates a HDC with CreateDC, and then incorrectly tries to release it with ReleaseDC instead of DeleteDC. This results in a GDI object leak every time the function is called, eventually leading to a crash of the application.

      See <http://msdn.microsoft.com/en-us/library/windows/desktop/dd162920(v=vs.85).aspx> :

      An application cannot use the ReleaseDC function to release a DC that was created by calling the CreateDC function; instead, it must use the DeleteDC function.

      The attached patch against Qt 5.3 replaces ReleaseDC with DeleteDC, which fixes the leak we observed.

      Attachments

        For Gerrit Dashboard: QTBUG-41941
        # Subject Branch Project Status CR V

        Activity

          People

            srutledg Shawn Rutledge
            jcugniere Julien Cugnière
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes