From 591bce8f6877ffb8e4ab81330ec077231eb2aab7 Mon Sep 17 00:00:00 2001
From: Andy Shaw <andy.shaw@digia.com>
Date: Fri, 17 Oct 2014 12:48:02 +0200
Subject: [PATCH] Get the correct available resolutions from the printer

On Windows the resolutions are available in pairs so get the y
resolution from each pair as the y resolution is the one that is actually
useful in QtPrintSupport terms

Task-number: QTBUG-42007
Change-Id: I02c0588dd97c541e679f22431435751563caadb2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
---
 src/plugins/printsupport/windows/qwindowsprintdevice.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
index 0a21193216d..0feea5ea745 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
@@ -280,11 +280,11 @@ void QWindowsPrintDevice::loadResolutions() const
 {
     DWORD resCount = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_ENUMRESOLUTIONS, NULL, NULL);
     if (int(resCount) > 0) {
-        QScopedArrayPointer<LONG> resolutions(new LONG[resCount*sizeof(LONG)]);
+        QScopedArrayPointer<LONG> resolutions(new LONG[resCount*2]);
         // Get the details and match the default paper size
         if (DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_ENUMRESOLUTIONS, (LPWSTR)resolutions.data(), NULL) == resCount) {
-            for (int i = 0; i < int(resCount); ++i)
-                m_resolutions.append(resolutions[i]);
+            for (int i = 0; i < int(resCount * 2); i += 2)
+                m_resolutions.append(resolutions[i+1]);
         }
     }
     m_haveResolutions = true;
-- 
GitLab