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

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

XMLWordPrintable

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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes