Ticket #48129: qt4-mac.10.11.diff

File qt4-mac.10.11.diff, 6.0 KB (added by michaelld (Michael Dickens), 9 years ago)
  • Portfile

     
    238238patchfiles-append   \
    239239    patch-tools_macdeployqt_shared_shared.cpp.diff
    240240
    241 # error out if trying to build on a new OSX version (> 10.10).
     241# (23) remove ColorSync usage from qpaintengine.
    242242
     243# This patch allows for building using the 10.11 SDK, and is also
     244# backward compatible with prior OS versions since it just removes API
     245# usage but does not otherwise add any. This patch does roughly the
     246# same thing as that from Qt5 commit b06304e16:
     247# http://code.qt.io/cgit/qt/qtbase.git/commit/?id=b06304e164ba47351fa292662c1e6383c081b5ca
     248
     249patchfiles-append   \
     250    patch-src_gui_painting_qpaintengine_mac.diff
     251
     252# error out if trying to build on a new OSX version (> 10.11).
     253
    243254platform darwin {
    244     if {${MINOR} > 10} {
     255    if {${MINOR} > 11} {
    245256        # This project needs to be updated to build with clang++ against libc++
    246257        depends_lib
    247258        depends_run
    248259        pre-fetch {
    249             ui_error "$name does not currently build on OSX later than 10.10 'Yosemite'."
     260            ui_error "$name does not currently build on OSX later than 10.11 'El Capitan'."
    250261            error "unsupported platform"
    251262        }
    252263    }
  • files/patch-src_gui_painting_qpaintengine_mac.diff

     
     1--- src/gui/painting/qpaintengine_mac.cpp.orig
     2+++ src/gui/painting/qpaintengine_mac.cpp
     3@@ -289,7 +289,7 @@ static CGMutablePathRef qt_mac_compose_path(const QPainterPath &p, float off=0)
     4 }
     5 
     6 CGColorSpaceRef QCoreGraphicsPaintEngine::m_genericColorSpace = 0;
     7-QHash<QWidget*, CGColorSpaceRef> QCoreGraphicsPaintEngine::m_displayColorSpaceHash; // window -> color space
     8+QHash<CGDirectDisplayID, CGColorSpaceRef> QCoreGraphicsPaintEngine::m_displayColorSpaceHash;
     9 bool QCoreGraphicsPaintEngine::m_postRoutineRegistered = false;
     10 
     11 CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace()
     12@@ -318,48 +318,31 @@ CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace()
     13 
     14 CGColorSpaceRef QCoreGraphicsPaintEngine::macDisplayColorSpace(const QWidget *widget)
     15 {
     16-    // The color space depends on which screen the widget's window is on.
     17-    // widget == 0 is a spacial case where we use the main display.
     18-    QWidget *window = widget ? widget->window() : 0;
     19+    CGColorSpaceRef colorSpace;
     20 
     21-    // Check for cached color space and return if found.
     22-    if (m_displayColorSpaceHash.contains(window))
     23-        return m_displayColorSpaceHash.value(window);
     24-
     25-    // Find which display the window is on.
     26     CGDirectDisplayID displayID;
     27-    if (window == 0) {
     28+    if (widget == 0) {
     29         displayID = CGMainDisplayID();
     30     } else {
     31-        const QRect &qrect = window->geometry();
     32+        const QRect &qrect = widget->window()->geometry();
     33         CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height());
     34         CGDisplayCount throwAway;
     35         CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
     36         if (dErr != kCGErrorSuccess)
     37-            displayID = CGMainDisplayID();
     38-    }
     39-
     40-    // Get the color space from the display profile.
     41-    CGColorSpaceRef colorSpace = 0;
     42-    CMProfileRef displayProfile = 0;
     43-    CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile);
     44-    if (err == noErr) {
     45-        colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile);
     46-        CMCloseProfile(displayProfile);
     47+            return macDisplayColorSpace(0); // fall back on main display
     48     }
     49+    if ((colorSpace = m_displayColorSpaceHash.value(displayID)))
     50+        return colorSpace;
     51 
     52-    // Fallback: use generic DeviceRGB
     53+    colorSpace = CGDisplayCopyColorSpace(displayID);
     54     if (colorSpace == 0)
     55         colorSpace = CGColorSpaceCreateDeviceRGB();
     56 
     57-    // Install cleanup routines
     58+    m_displayColorSpaceHash.insert(displayID, colorSpace);
     59     if (!m_postRoutineRegistered) {
     60         m_postRoutineRegistered = true;
     61         qAddPostRoutine(QCoreGraphicsPaintEngine::cleanUpMacColorSpaces);
     62     }
     63-
     64-    // Cache and return.
     65-    m_displayColorSpaceHash.insert(window, colorSpace);
     66     return colorSpace;
     67 }
     68 
     69@@ -369,7 +352,7 @@ void QCoreGraphicsPaintEngine::cleanUpMacColorSpaces()
     70         CFRelease(m_genericColorSpace);
     71         m_genericColorSpace = 0;
     72     }
     73-    QHash<QWidget*, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
     74+    QHash<CGDirectDisplayID, CGColorSpaceRef>::const_iterator it = m_displayColorSpaceHash.constBegin();
     75     while (it != m_displayColorSpaceHash.constEnd()) {
     76         if (it.value())
     77             CFRelease(it.value());
     78@@ -1069,7 +1052,16 @@ void QCoreGraphicsPaintEngine::cleanup()
     79 
     80 void QCoreGraphicsPaintEngine::clearColorSpace(QWidget* w)
     81 {
     82-    m_displayColorSpaceHash.remove(w);
     83+    CGDirectDisplayID displayID = CGMainDisplayID();
     84+    if (w != 0) {
     85+        const QRect &qrect = w->window()->geometry();
     86+        CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height());
     87+        CGDisplayCount throwAway;
     88+        CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
     89+        if (dErr != kCGErrorSuccess)
     90+           displayID = CGMainDisplayID();
     91+    }
     92+    m_displayColorSpaceHash.remove(displayID);
     93 }
     94 
     95 CGContextRef
     96--- src/gui/painting/qpaintengine_mac_p.h.orig
     97+++ src/gui/painting/qpaintengine_mac_p.h
     98@@ -135,7 +135,7 @@ protected:
     99 private:
     100     static bool m_postRoutineRegistered;
     101     static CGColorSpaceRef m_genericColorSpace;
     102-    static QHash<QWidget*, CGColorSpaceRef> m_displayColorSpaceHash; // window -> color space
     103+    static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
     104     static void cleanUpMacColorSpaces();
     105     Q_DISABLE_COPY(QCoreGraphicsPaintEngine)
     106 };