Ticket #44017: qt4-mac-10.10_min.diff

File qt4-mac-10.10_min.diff, 47.8 KB (added by michaelld (Michael Dickens), 10 years ago)

Trial patch to MacPorts dports for qt4-mac for 10.10 minimum changes

  • Portfile

    old new  
    240240patchfiles-append   \
    241241    patch-tools_macdeployqt_shared_shared.cpp.diff
    242242
    243 # error out if trying to build on a new OSX version (> 10.9).
     243# (24) minimum patches required for 10.10; squashed; temporary until 4.8.7.
    244244
     245patchfiles-append   \
     246    patch-10.10.diff
     247
     248# error out if trying to build on a new OSX version (> 10.10).
     249
    245250platform darwin {
    246     if {${MINOR} > 9} {
     251    if {${MINOR} > 10} {
    247252        # This project needs to be updated to build with clang++ against libc++
    248253        depends_lib
    249254        depends_run
    250255        pre-fetch {
    251             ui_error "$name does not currently build on OSX later than 10.9 'Mavericks'."
     256            ui_error "$name does not currently build on OSX later than 10.10 'Yosemite'."
    252257            error "unsupported platform"
    253258        }
    254259    }
  • files/patch-10.10.diff

    old new  
     1--- src/corelib/global/qglobal.cpp.orig
     2+++ src/corelib/global/qglobal.cpp
     3@@ -1185,6 +1185,7 @@ bool qSharedBuild()
     4     \value MV_10_7     OS X 10.7
     5     \value MV_10_8     OS X 10.8
     6     \value MV_10_9     OS X 10.9
     7+    \value MV_10_10    OS X 10.10
     8     \value MV_Unknown  An unknown and currently unsupported platform
     9 
     10     \value MV_CHEETAH  Apple codename for MV_10_0
     11@@ -1197,6 +1198,7 @@ bool qSharedBuild()
     12     \value MV_LION     Apple codename for MV_10_7
     13     \value MV_MOUNTAINLION Apple codename for MV_10_8
     14     \value MV_MAVERICKS    Apple codename for MV_10_9
     15+    \value MV_YOSEMITE     Apple codename for MV_10_10
     16 
     17     \sa WinVersion, SymbianVersion
     18 */
     19@@ -1674,8 +1676,9 @@ static QSysInfo::MacVersion macVersion()
     20 {
     21 #if !defined(Q_OS_IOS)
     22     SInt32 gestalt_version;
     23-    if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
     24-        return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
     25+    if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) {
     26+        // add 2 because OS X 10.0 is 0x02 in the enum
     27+        return QSysInfo::MacVersion(gestalt_version + 2);
     28     }
     29 #endif
     30     return QSysInfo::MV_Unknown;
     31--- src/corelib/global/qglobal.h.orig
     32+++ src/corelib/global/qglobal.h
     33@@ -304,31 +304,69 @@ namespace QT_NAMESPACE {}
     34 #endif
     35 
     36 #ifdef Q_OS_DARWIN
     37-#  ifdef MAC_OS_X_VERSION_MIN_REQUIRED
     38-#    undef MAC_OS_X_VERSION_MIN_REQUIRED
     39-#  endif
     40-#  define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
     41 #  include <AvailabilityMacros.h>
     42-#  if !defined(MAC_OS_X_VERSION_10_3)
     43-#     define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1
     44+#
     45+#  // Availability.h was introduced with the OS X 10.6 SDK
     46+#  if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060) || \
     47+      (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
     48+#    include <Availability.h>
     49+#  endif
     50+#
     51+#  ifdef Q_OS_MACX
     52+#    if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < 1040
     53+#       undef __MAC_OS_X_VERSION_MIN_REQUIRED
     54+#       define __MAC_OS_X_VERSION_MIN_REQUIRED 1040
     55+#    endif
     56+#    if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < 1040
     57+#       undef MAC_OS_X_VERSION_MIN_REQUIRED
     58+#       define MAC_OS_X_VERSION_MIN_REQUIRED 1040
     59+#    endif
     60+#  endif
     61+#
     62+#  // Numerical checks are preferred to named checks, but to be safe
     63+#  // we define the missing version names in case Qt uses them.
     64+#
     65+#  if !defined(__MAC_10_4)
     66+#       define __MAC_10_4 1040
     67+#  endif
     68+#  if !defined(__MAC_10_5)
     69+#       define __MAC_10_5 1050
     70+#  endif
     71+#  if !defined(__MAC_10_6)
     72+#       define __MAC_10_6 1060
     73+#  endif
     74+#  if !defined(__MAC_10_7)
     75+#       define __MAC_10_7 1070
     76+#  endif
     77+#  if !defined(__MAC_10_8)
     78+#       define __MAC_10_8 1080
     79+#  endif
     80+#  if !defined(__MAC_10_9)
     81+#       define __MAC_10_9 1090
     82+#  endif
     83+#  if !defined(__MAC_10_10)
     84+#       define __MAC_10_10 101000
     85 #  endif
     86 #  if !defined(MAC_OS_X_VERSION_10_4)
     87-#       define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1
     88+#       define MAC_OS_X_VERSION_10_4 1040
     89 #  endif
     90 #  if !defined(MAC_OS_X_VERSION_10_5)
     91-#       define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1
     92+#       define MAC_OS_X_VERSION_10_5 1050
     93 #  endif
     94 #  if !defined(MAC_OS_X_VERSION_10_6)
     95-#       define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
     96+#       define MAC_OS_X_VERSION_10_6 1060
     97 #  endif
     98 #  if !defined(MAC_OS_X_VERSION_10_7)
     99-#       define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1
     100+#       define MAC_OS_X_VERSION_10_7 1070
     101 #  endif
     102 #  if !defined(MAC_OS_X_VERSION_10_8)
     103-#       define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1
     104+#       define MAC_OS_X_VERSION_10_8 1080
     105 #  endif
     106 #  if !defined(MAC_OS_X_VERSION_10_9)
     107-#       define MAC_OS_X_VERSION_10_9 MAC_OS_X_VERSION_10_8 + 1
     108+#       define MAC_OS_X_VERSION_10_9 1090
     109+#  endif
     110+#  if !defined(MAC_OS_X_VERSION_10_10)
     111+#       define MAC_OS_X_VERSION_10_10 101000
     112 #  endif
     113 #endif
     114 
     115@@ -1630,6 +1668,7 @@ public:
     116         MV_10_7 = 0x0009,
     117         MV_10_8 = 0x000A,
     118         MV_10_9 = 0x000B,
     119+        MV_10_10 = 0x000C,
     120 
     121         /* codenames */
     122         MV_CHEETAH = MV_10_0,
     123@@ -1641,7 +1680,8 @@ public:
     124         MV_SNOWLEOPARD = MV_10_6,
     125         MV_LION = MV_10_7,
     126         MV_MOUNTAINLION = MV_10_8,
     127-        MV_MAVERICKS = MV_10_9
     128+        MV_MAVERICKS = MV_10_9,
     129+        MV_YOSEMITE = MV_10_10
     130     };
     131     static const MacVersion MacintoshVersion;
     132 #endif
     133--- src/gui/dialogs/qcolordialog_mac.mm.orig
     134+++ src/gui/dialogs/qcolordialog_mac.mm
     135@@ -318,7 +318,7 @@ QT_USE_NAMESPACE
     136         // It's important that the modal event loop is stopped before
     137         // we accept/reject QColorDialog, since QColorDialog has its
     138         // own event loop that needs to be stopped last.
     139-        [NSApp stopModalWithCode:code];
     140+        [[NSApplication sharedApplication] stopModalWithCode:code];
     141     } else {
     142         // Since we are not in a modal event loop, we can safely close
     143         // down QColorDialog
     144@@ -350,7 +350,7 @@ QT_USE_NAMESPACE
     145     while (!modalEnded) {
     146 #ifndef QT_NO_EXCEPTIONS
     147         @try {
     148-            [NSApp runModalForWindow:mColorPanel];
     149+            [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
     150             modalEnded = true;
     151         } @catch (NSException *) {
     152             // For some reason, NSColorPanel throws an exception when
     153@@ -358,7 +358,7 @@ QT_USE_NAMESPACE
     154             // palette (tab three).
     155         }
     156 #else
     157-        [NSApp runModalForWindow:mColorPanel];
     158+        [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
     159         modalEnded = true;
     160 #endif
     161     }
     162@@ -469,10 +469,10 @@ void QColorDialogPrivate::mac_nativeDialogModalHelp()
     163     // Do a queued meta-call to open the native modal dialog so it opens after the new
     164     // event loop has started to execute (in QDialog::exec). Using a timer rather than
     165     // a queued meta call is intentional to ensure that the call is only delivered when
     166-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
     167+    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
     168     // running (which is the case if e.g a top-most QEventLoop has been
     169     // interrupted, and the second-most event loop has not yet been reactivated (regardless
     170-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
     171+    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
     172     if (delegate){
     173         Q_Q(QColorDialog);
     174         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
     175--- src/gui/dialogs/qfiledialog_mac.mm.orig
     176+++ src/gui/dialogs/qfiledialog_mac.mm
     177@@ -229,7 +229,7 @@ QT_USE_NAMESPACE
     178     if ([mSavePanel respondsToSelector:@selector(close)])
     179         [mSavePanel close];
     180     if ([mSavePanel isSheet])
     181-        [NSApp endSheet: mSavePanel];
     182+        [[NSApplication sharedApplication] endSheet: mSavePanel];
     183 }
     184 
     185 - (void)showModelessPanel
     186@@ -1162,10 +1162,10 @@ void QFileDialogPrivate::mac_nativeDialogModalHelp()
     187     // Do a queued meta-call to open the native modal dialog so it opens after the new
     188     // event loop has started to execute (in QDialog::exec). Using a timer rather than
     189     // a queued meta call is intentional to ensure that the call is only delivered when
     190-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
     191+    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
     192     // running (which is the case if e.g a top-most QEventLoop has been
     193     // interrupted, and the second-most event loop has not yet been reactivated (regardless
     194-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
     195+    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
     196     if (nativeDialogInUse){
     197         Q_Q(QFileDialog);
     198         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
     199--- src/gui/dialogs/qfontdialog_mac.mm.orig
     200+++ src/gui/dialogs/qfontdialog_mac.mm
     201@@ -230,7 +230,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     202     mAppModal = true;
     203     NSWindow *ourPanel = [mStolenContentView window];
     204     [ourPanel setReleasedWhenClosed:NO];
     205-    [NSApp runModalForWindow:ourPanel];
     206+    [[NSApplication sharedApplication] runModalForWindow:ourPanel];
     207     QAbstractEventDispatcher::instance()->interrupt();
     208 
     209     if (mReturnCode == NSOKButton)
     210@@ -256,7 +256,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     211 
     212     mAppModal = false;
     213     NSWindow *ourPanel = [mStolenContentView window];
     214-    [NSApp beginSheet:ourPanel
     215+    [[NSApplication sharedApplication] beginSheet:ourPanel
     216         modalForWindow:window
     217         modalDelegate:0
     218         didEndSelector:0
     219@@ -456,7 +456,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     220 
     221     if (mAppModal) {
     222         mReturnCode = code;
     223-        [NSApp stopModalWithCode:code];
     224+        [[NSApplication sharedApplication] stopModalWithCode:code];
     225     } else {
     226         if (code == NSOKButton)
     227             mPriv->fontDialog()->accept();
     228@@ -636,10 +636,10 @@ void QFontDialogPrivate::mac_nativeDialogModalHelp()
     229     // Do a queued meta-call to open the native modal dialog so it opens after the new
     230     // event loop has started to execute (in QDialog::exec). Using a timer rather than
     231     // a queued meta call is intentional to ensure that the call is only delivered when
     232-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
     233+    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
     234     // running (which is the case if e.g a top-most QEventLoop has been
     235     // interrupted, and the second-most event loop has not yet been reactivated (regardless
     236-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
     237+    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
     238     if (nativeDialogInUse) {
     239         Q_Q(QFontDialog);
     240         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
     241--- src/gui/kernel/qapplication_mac.mm.orig
     242+++ src/gui/kernel/qapplication_mac.mm
     243@@ -468,7 +468,7 @@ void qt_mac_set_app_icon(const QPixmap &pixmap)
     244         image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
     245     }
     246 
     247-    [NSApp setApplicationIconImage:image];
     248+    [[NSApplication sharedApplication] setApplicationIconImage:image];
     249     [image release];
     250 #endif
     251 }
     252@@ -750,7 +750,7 @@ void qt_event_request_showsheet(QWidget *w)
     253     Q_ASSERT(qt_mac_is_macsheet(w));
     254 #ifdef QT_MAC_USE_COCOA
     255     w->repaint();
     256-    [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
     257+    [[NSApplication sharedApplication] beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
     258         modalDelegate:nil didEndSelector:nil contextInfo:0];
     259 #else
     260     qt_mac_event_remove(request_showsheet_pending);
     261@@ -992,7 +992,7 @@ Q_GUI_EXPORT void qt_mac_set_dock_menu(QMenu *menu)
     262 {
     263     qt_mac_dock_menu = menu;
     264 #ifdef QT_MAC_USE_COCOA
     265-    [NSApp setDockMenu:menu->macMenu()];
     266+    [[NSApplication sharedApplication] setDockMenu:menu->macMenu()];
     267 #else
     268     SetApplicationDockTileMenu(menu->macMenu());
     269 #endif
     270@@ -1011,7 +1011,7 @@ void qt_mac_event_release(QWidget *w)
     271 #ifndef QT_MAC_USE_COCOA
     272             SetApplicationDockTileMenu(0);
     273 #else
     274-            [NSApp setDockMenu:0];
     275+            [[NSApplication sharedApplication] setDockMenu:0];
     276 #endif
     277         }
     278     }
     279@@ -1463,7 +1463,7 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
     280     NSWindowList(windowCount, windowList.data());
     281     int firstQtWindowFound = -1;
     282     for (int i = 0; i < windowCount; ++i) {
     283-        NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
     284+        NSWindow *window = [[NSApplication sharedApplication] windowWithWindowNumber:windowList[i]];
     285         if (window) {
     286             QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
     287             if (candidateWindow && firstQtWindowFound == -1)
     288@@ -3071,7 +3071,7 @@ bool QApplicationPrivate::canQuit()
     289 #else
     290     Q_Q(QApplication);
     291 #ifdef QT_MAC_USE_COCOA
     292-    [[NSApp mainMenu] cancelTracking];
     293+    [[[NSApplication sharedApplication] mainMenu] cancelTracking];
     294 #else
     295     HiliteMenu(0);
     296 #endif
     297@@ -3146,7 +3146,7 @@ void onApplicationChangedActivation( bool activated )
     298         }
     299 
     300         if (!app->activeWindow()) {
     301-            OSWindowRef wp = [NSApp keyWindow];
     302+            OSWindowRef wp = [[NSApplication sharedApplication] keyWindow];
     303             if (QWidget *tmp_w = qt_mac_find_window(wp))
     304                 app->setActiveWindow(tmp_w);
     305         }
     306--- src/gui/kernel/qcocoaapplication_mac.mm.orig
     307+++ src/gui/kernel/qcocoaapplication_mac.mm
     308@@ -147,7 +147,7 @@ QT_USE_NAMESPACE
     309     if ([event type] == NSApplicationDefined) {
     310         switch ([event subtype]) {
     311             case QtCocoaEventSubTypePostMessage:
     312-                [NSApp QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
     313+                [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
     314                 return true;
     315             default:
     316                 break;
     317@@ -174,7 +174,7 @@ QT_USE_NAMESPACE
     318     // be called instead of sendEvent if redirection occurs.
     319     // 'self' will then be an instance of NSApplication
     320     // (and not QNSApplication)
     321-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
     322+    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
     323         [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
     324 }
     325 
     326@@ -182,7 +182,7 @@ QT_USE_NAMESPACE
     327 {
     328     // This method will be called if
     329     // no redirection occurs
     330-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
     331+    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
     332         [super sendEvent:event];
     333 }
     334 
     335@@ -194,7 +194,7 @@ QT_USE_NAMESPACE
     336     // visible on screen. Note: If Qt is used as a plugin, Qt will not use a
     337     // native menu bar. Hence, we will also not need to do any redirection etc. as
     338     // we do with sendEvent.
     339-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
     340+    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
     341 }
     342 
     343 @end
     344@@ -203,7 +203,7 @@ QT_BEGIN_NAMESPACE
     345 
     346 void qt_redirectNSApplicationSendEvent()
     347 {
     348-    if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
     349+    if ([[NSApplication sharedApplication] isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
     350         // No need to change implementation since Qt
     351         // already controls a subclass of NSApplication
     352         return;
     353--- src/gui/kernel/qcocoaapplicationdelegate_mac.mm.orig
     354+++ src/gui/kernel/qcocoaapplicationdelegate_mac.mm
     355@@ -122,7 +122,7 @@ static void cleanupCocoaApplicationDelegate()
     356     [dockMenu release];
     357     [qtMenuLoader release];
     358     if (reflectionDelegate) {
     359-        [NSApp setDelegate:reflectionDelegate];
     360+        [[NSApplication sharedApplication] setDelegate:reflectionDelegate];
     361         [reflectionDelegate release];
     362     }
     363     [super dealloc];
     364@@ -183,7 +183,7 @@ static void cleanupCocoaApplicationDelegate()
     365     return [[qtMenuLoader retain] autorelease];
     366 }
     367 
     368-// This function will only be called when NSApp is actually running. Before
     369+// This function will only be called when NSApplication is actually running. Before
     370 // that, the kAEQuitApplication Apple event will be sent to
     371 // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
     372 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
     373@@ -249,7 +249,7 @@ static void cleanupCocoaApplicationDelegate()
     374         && [reflectionDelegate respondsToSelector:
     375                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
     376         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
     377-    return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
     378+    return NO; // Someday qApp->quitOnLastWindowClosed(); when qApp and NSApplication work closer together.
     379 }
     380 
     381 
     382@@ -289,13 +289,26 @@ static void cleanupCocoaApplicationDelegate()
     383     qt_button_down = 0;
     384 }
     385 
     386+- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
     387+{
     388+    Q_UNUSED(theApplication);
     389+    Q_UNUSED(flag);
     390+    // The reflection delegate gets precedence
     391+    if (reflectionDelegate
     392+        && [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
     393+        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
     394+
     395+    onApplicationChangedActivation(true);
     396+    return NO;
     397+}
     398+
     399 - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
     400 {
     401     Q_UNUSED(notification);
     402     QDesktopWidgetImplementation::instance()->onResize();
     403 }
     404 
     405-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
     406+- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate
     407 {
     408     [oldDelegate retain];
     409     [reflectionDelegate release];
     410@@ -342,12 +355,12 @@ static void cleanupCocoaApplicationDelegate()
     411 {
     412     Q_UNUSED(event);
     413     Q_UNUSED(replyEvent);
     414-    [NSApp terminate:self];
     415+    [[NSApplication sharedApplication] terminate:self];
     416 }
     417 
     418 - (void)qtDispatcherToQAction:(id)sender
     419 {
     420-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
     421+    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
     422 }
     423 
     424 @end
     425--- src/gui/kernel/qcocoaapplicationdelegate_mac_p.h.orig
     426+++ src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
     427@@ -113,7 +113,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
     428     QApplicationPrivate *qtPrivate;
     429     NSMenu *dockMenu;
     430     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
     431-    NSObject <NSApplicationDelegate> *reflectionDelegate;
     432+    id <NSApplicationDelegate> reflectionDelegate;
     433     bool inLaunch;
     434 }
     435 + (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
     436@@ -122,7 +122,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
     437 - (QApplicationPrivate *)qAppPrivate;
     438 - (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
     439 - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
     440-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
     441+- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate;
     442 - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
     443 @end
     444 #endif
     445--- src/gui/kernel/qcocoamenuloader_mac.mm.orig
     446+++ src/gui/kernel/qcocoamenuloader_mac.mm
     447@@ -92,8 +92,8 @@ QT_USE_NAMESPACE
     448     // 'Quit' item. When changing menu bar (e.g when switching between
     449     // windows with different menu bars), we never recreate this menu, but
     450     // instead pull it out the current menu bar and place into the new one:
     451-    NSMenu *mainMenu = [NSApp mainMenu];
     452-    if ([NSApp mainMenu] == menu)
     453+    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
     454+    if ([[NSApplication sharedApplication] mainMenu] == menu)
     455         return; // nothing to do (menu is the current menu bar)!
     456 
     457 #ifndef QT_NAMESPACE
     458@@ -201,27 +201,27 @@ QT_USE_NAMESPACE
     459 
     460 - (void)terminate:(id)sender
     461 {
     462-    [NSApp terminate:sender];
     463+    [[NSApplication sharedApplication] terminate:sender];
     464 }
     465 
     466 - (void)orderFrontStandardAboutPanel:(id)sender
     467 {
     468-    [NSApp orderFrontStandardAboutPanel:sender];
     469+    [[NSApplication sharedApplication] orderFrontStandardAboutPanel:sender];
     470 }
     471 
     472 - (void)hideOtherApplications:(id)sender
     473 {
     474-    [NSApp hideOtherApplications:sender];
     475+    [[NSApplication sharedApplication] hideOtherApplications:sender];
     476 }
     477 
     478 - (void)unhideAllApplications:(id)sender
     479 {
     480-    [NSApp unhideAllApplications:sender];
     481+    [[NSApplication sharedApplication] unhideAllApplications:sender];
     482 }
     483 
     484 - (void)hide:(id)sender
     485 {
     486-    [NSApp hide:sender];
     487+    [[NSApplication sharedApplication] hide:sender];
     488 }
     489 
     490 - (void)qtUpdateMenubar
     491@@ -258,7 +258,7 @@ QT_USE_NAMESPACE
     492 
     493  - (void)orderFrontCharacterPalette:(id)sender
     494  {
     495-     [NSApp orderFrontCharacterPalette:sender];
     496+     [[NSApplication sharedApplication] orderFrontCharacterPalette:sender];
     497  }
     498 
     499 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem
     500@@ -266,7 +266,7 @@ QT_USE_NAMESPACE
     501     if ([menuItem action] == @selector(hide:)
     502         || [menuItem action] == @selector(hideOtherApplications:)
     503         || [menuItem action] == @selector(unhideAllApplications:)) {
     504-        return [NSApp validateMenuItem:menuItem];
     505+        return [[NSApplication sharedApplication] validateMenuItem:menuItem];
     506     } else {
     507         return [menuItem isEnabled];
     508     }
     509--- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h.orig
     510+++ src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
     511@@ -143,7 +143,7 @@ QT_END_NAMESPACE
     512 {
     513     // This function is called from the quit item in the menubar when this window
     514     // is in the first responder chain (see also qtDispatcherToQAction above)
     515-    [NSApp terminate:sender];
     516+    [[NSApplication sharedApplication] terminate:sender];
     517 }
     518 
     519 - (void)setLevel:(NSInteger)windowLevel
     520@@ -364,7 +364,7 @@ QT_END_NAMESPACE
     521 
     522     if ([sender draggingSource] != nil) {
     523         // modifier flags might have changed, update it here since we don't send any input events.
     524-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
     525+        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
     526         modifiers = QApplication::keyboardModifiers();
     527     } else {
     528         // when the source is from another application the above technique will not work.
     529@@ -456,7 +456,7 @@ QT_END_NAMESPACE
     530 
     531     // Update modifiers:
     532     if ([sender draggingSource] != nil) {
     533-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
     534+        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
     535         modifiers = QApplication::keyboardModifiers();
     536     } else {
     537         modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
     538--- src/gui/kernel/qeventdispatcher_mac.mm.orig
     539+++ src/gui/kernel/qeventdispatcher_mac.mm
     540@@ -461,7 +461,7 @@ static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event,
     541     if (pt)
     542         [pt sendEvent:event];
     543     else
     544-        [NSApp sendEvent:event];
     545+        [[NSApplication sharedApplication] sendEvent:event];
     546     return true;
     547 #endif
     548 }
     549@@ -521,12 +521,12 @@ static inline void qt_mac_waitForMoreEvents()
     550     // (and free up cpu time) until at least one event occur.
     551     // This implementation is a bit on the edge, but seems to
     552     // work fine:
     553-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
     554+    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
     555         untilDate:[NSDate distantFuture]
     556         inMode:NSDefaultRunLoopMode
     557         dequeue:YES];
     558     if (event)
     559-        [NSApp postEvent:event atStart:YES];
     560+        [[NSApplication sharedApplication] postEvent:event atStart:YES];
     561 #endif
     562 }
     563 
     564@@ -537,12 +537,12 @@ static inline void qt_mac_waitForMoreModalSessionEvents()
     565     // (and free up cpu time) until at least one event occur.
     566     // This implementation is a bit on the edge, but seems to
     567     // work fine:
     568-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
     569+    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
     570         untilDate:[NSDate distantFuture]
     571         inMode:NSModalPanelRunLoopMode
     572         dequeue:YES];
     573     if (event)
     574-        [NSApp postEvent:event atStart:YES];
     575+        [[NSApplication sharedApplication] postEvent:event atStart:YES];
     576 }
     577 #endif
     578 
     579@@ -588,23 +588,23 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     580         // done from the application itself. And if processEvents is called
     581         // manually (rather than from a QEventLoop), we cannot enter a tight
     582         // loop and block this call, but instead we need to return after one flush.
     583-        // Finally, if we are to exclude user input events, we cannot call [NSApp run]
     584+        // Finally, if we are to exclude user input events, we cannot call [NSApplication run]
     585         // as we then loose control over which events gets dispatched:
     586-        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
     587+        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![[NSApplication sharedApplication] isRunning];
     588         const bool canExec_Qt = !excludeUserEvents &&
     589                 (flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec) ;
     590 
     591         if (canExec_Qt && canExec_3rdParty) {
     592             // We can use exec-mode, meaning that we can stay in a tight loop until
     593             // interrupted. This is mostly an optimization, but it allow us to use
     594-            // [NSApp run], which is the normal code path for cocoa applications.
     595+            // [NSApplication run], which is the normal code path for cocoa applications.
     596             if (NSModalSession session = d->currentModalSession()) {
     597                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
     598-                while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
     599+                while ([[NSApplication sharedApplication] runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
     600                     qt_mac_waitForMoreModalSessionEvents();
     601 
     602                 if (!d->interrupt && session == d->currentModalSessionCached) {
     603-                    // Someone called [NSApp stopModal:] from outside the event
     604+                    // Someone called [[NSApplication sharedApplication] stopModal:] from outside the event
     605                     // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
     606                     // 'session' as well. As a result, we need to restart all internal sessions:
     607                     d->temporarilyStopAllModalSessions();
     608@@ -612,7 +612,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     609             } else {
     610                 d->nsAppRunCalledByQt = true;
     611                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
     612-                [NSApp run];
     613+                [[NSApplication sharedApplication] run];
     614             }
     615             retVal = true;
     616         } else {
     617@@ -626,9 +626,9 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     618                     // to use cocoa's native way of running modal sessions:
     619                     if (flags & QEventLoop::WaitForMoreEvents)
     620                         qt_mac_waitForMoreModalSessionEvents();
     621-                    NSInteger status = [NSApp runModalSession:session];
     622+                    NSInteger status = [[NSApplication sharedApplication] runModalSession:session];
     623                     if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
     624-                        // INVARIANT: Someone called [NSApp stopModal:] from outside the event
     625+                        // INVARIANT: Someone called [NSApplication stopModal:] from outside the event
     626                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
     627                         // 'session' as well. As a result, we need to restart all internal sessions:
     628                         d->temporarilyStopAllModalSessions();
     629@@ -637,8 +637,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     630                 } else do {
     631                     // Dispatch all non-user events (but que non-user events up for later). In
     632                     // this case, we need more control over which events gets dispatched, and
     633-                    // cannot use [NSApp runModalSession:session]:
     634-                    event = [NSApp nextEventMatchingMask:NSAnyEventMask
     635+                    // cannot use [NSApplication runModalSession:session]:
     636+                    event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
     637                     untilDate:nil
     638                     inMode:NSModalPanelRunLoopMode
     639                     dequeue: YES];
     640@@ -655,7 +655,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     641                 } while (!d->interrupt && event != nil);
     642             } else do {
     643                 // INVARIANT: No modal window is executing.
     644-                event = [NSApp nextEventMatchingMask:NSAnyEventMask
     645+                event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
     646                 untilDate:nil
     647                 inMode:NSDefaultRunLoopMode
     648                 dequeue: YES];
     649@@ -798,12 +798,12 @@ void QEventDispatcherMacPrivate::ensureNSAppInitialized()
     650     // we let Cocoa finish the initialization it seems to need. We'll only
     651     // apply this trick at most once for any application, and we avoid doing it
     652     // for the common case where main just starts QApplication::exec.
     653-    if (nsAppRunCalledByQt || [NSApp isRunning])
     654+    if (nsAppRunCalledByQt || [[NSApplication sharedApplication] isRunning])
     655         return;
     656     nsAppRunCalledByQt = true;
     657     QBoolBlocker block1(interrupt, true);
     658     QBoolBlocker block2(currentExecIsNSAppRun, true);
     659-    [NSApp run];
     660+    [[NSApplication sharedApplication] run];
     661 }
     662 
     663 void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
     664@@ -812,8 +812,8 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
     665     // such, make them pending again. The next call to
     666     // currentModalSession will recreate them again. The
     667     // reason to stop all session like this is that otherwise
     668-    // a call [NSApp stop] would not stop NSApp, but rather
     669-    // the current modal session. So if we need to stop NSApp
     670+    // a call [NSApplication stop] would not stop NSApplication, but rather
     671+    // the current modal session. So if we need to stop NSApplication
     672     // we need to stop all the modal session first. To avoid changing
     673     // the stacking order of the windows while doing so, we put
     674     // up a block that is used in QCocoaWindow and QCocoaPanel:
     675@@ -821,7 +821,7 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
     676     for (int i=0; i<stackSize; ++i) {
     677         QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
     678         if (info.session) {
     679-            [NSApp endModalSession:info.session];
     680+            [[NSApplication sharedApplication] endModalSession:info.session];
     681             info.session = 0;
     682         }
     683     }
     684@@ -856,7 +856,7 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
     685             info.nswindow = window;
     686             [(NSWindow*) info.nswindow retain];
     687             int levelBeforeEnterModal = [window level];
     688-            info.session = [NSApp beginModalSessionForWindow:window];
     689+            info.session = [[NSApplication sharedApplication] beginModalSessionForWindow:window];
     690             // Make sure we don't stack the window lower that it was before
     691             // entering modal, in case it e.g. had the stays-on-top flag set:
     692             if (levelBeforeEnterModal > [window level])
     693@@ -926,7 +926,7 @@ void QEventDispatcherMacPrivate::cleanupModalSessions()
     694         cocoaModalSessionStack.remove(i);
     695         currentModalSessionCached = 0;
     696         if (info.session) {
     697-            [NSApp endModalSession:info.session];
     698+            [[NSApplication sharedApplication] endModalSession:info.session];
     699             [(NSWindow *)info.nswindow release];
     700         }
     701     }
     702@@ -1057,7 +1057,7 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
     703             // pending cocoa events first).
     704             if (d->currentModalSessionCached)
     705                 d->temporarilyStopAllModalSessions();
     706-            [NSApp stop:NSApp];
     707+            [[NSApplication sharedApplication] stop:[NSApplication sharedApplication]];
     708             d->cancelWaitForMoreEvents();
     709         }
     710 #endif
     711@@ -1093,7 +1093,8 @@ void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
     712     // In case the event dispatcher is waiting for more
     713     // events somewhere, we post a dummy event to wake it up:
     714     QMacCocoaAutoReleasePool pool;
     715-    [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
     716+    [[NSApplication sharedApplication] postEvent:[NSEvent otherEventWithType:NSApplicationDefined
     717+        location:NSZeroPoint
     718         modifierFlags:0 timestamp:0. windowNumber:0 context:0
     719         subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
     720 }
     721@@ -1110,7 +1111,7 @@ void QEventDispatcherMac::interrupt()
     722 #else
     723     // We do nothing more here than setting d->interrupt = true, and
     724     // poke the event loop if it is sleeping. Actually stopping
     725-    // NSApp, or the current modal session, is done inside the send
     726+    // NSApplication, or the current modal session, is done inside the send
     727     // posted events callback. We do this to ensure that all current pending
     728     // cocoa events gets delivered before we stop. Otherwise, if we now stop
     729     // the last event loop recursion, cocoa will just drop pending posted
     730@@ -1165,7 +1166,7 @@ QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false)
     731     // The whole point of this class is that we enable a way to interrupt
     732     // the event dispatcher when returning back to a lower recursion level
     733     // than where interruptLater was called. This is needed to detect if
     734-    // [NSApp run] should still be running at the recursion level it is at.
     735+    // [NSApplication run] should still be running at the recursion level it is at.
     736     // Since the interrupt is canceled if processEvents is called before
     737     // this object gets deleted, we also avoid interrupting unnecessary.
     738     deleteLater();
     739--- src/gui/kernel/qt_cocoa_helpers_mac.mm.orig
     740+++ src/gui/kernel/qt_cocoa_helpers_mac.mm
     741@@ -1697,7 +1697,7 @@ void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2
     742     NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
     743         location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
     744         context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
     745-    [NSApp postEvent:e atStart:NO];
     746+    [[NSApplication sharedApplication] postEvent:e atStart:NO];
     747 }
     748 
     749 void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount, id arg1, id arg2)
     750@@ -1727,7 +1727,7 @@ void qt_mac_post_retranslateAppMenu()
     751 {
     752 #ifdef QT_MAC_USE_COCOA
     753     QMacCocoaAutoReleasePool pool;
     754-    qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
     755+    qt_cocoaPostMessage([[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
     756 #endif
     757 }
     758 
     759--- src/gui/kernel/qt_mac_p.h.orig
     760+++ src/gui/kernel/qt_mac_p.h
     761@@ -75,6 +75,62 @@
     762 
     763 #include <Carbon/Carbon.h>
     764 
     765+#if !defined(QT_MAC_USE_COCOA) && defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
     766+    // Some deprecated functions have been removed from the the 10.7 SDK, but the symbols are
     767+    // still exported by the 32-bit QD.framework (a subframework of ApplicationServices).
     768+    extern "C" {
     769+        // from QuickdrawAPI.h
     770+        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/QuickDraw_Ref/QuickDraw_Ref.pdf
     771+        void          CopyBits(const BitMap *srcBits, const BitMap *dstBits, const Rect *srcRect, const Rect *dstRect, short mode, RgnHandle maskRgn);
     772+        void          CopyRgn(RgnHandle srcRgn, RgnHandle dstRgn);
     773+        void          DisposeRgn(RgnHandle rgn);
     774+        GDHandle      GetMainDevice(void);
     775+        const BitMap *GetPortBitMapForCopyBits(CGrafPtr port);
     776+        Rect         *GetRegionBounds(RgnHandle region, Rect *bounds);
     777+        RgnHandle     NewRgn(void);
     778+        OSStatus      QDRegionToRects(RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void *userData);
     779+        void          SetEmptyRgn(RgnHandle rgn);
     780+        void          SetRect(Rect* r, short left, short top, short right, short bottom);
     781+        void          SetRectRgn(RgnHandle rgn, short left, short top, short right, short bottom);
     782+        void          UnionRgn(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
     783+        enum {
     784+            kQDRegionToRectsMsgInit       = 1,
     785+            kQDRegionToRectsMsgParse      = 2,
     786+            kQDRegionToRectsMsgTerminate  = 3
     787+        };
     788+        enum {
     789+            kQDParseRegionFromTop         = (1 << 0),
     790+            kQDParseRegionFromBottom      = (1 << 1),
     791+            kQDParseRegionFromLeft        = (1 << 2),
     792+            kQDParseRegionFromRight       = (1 << 3),
     793+            kQDParseRegionFromTopLeft     = kQDParseRegionFromTop | kQDParseRegionFromLeft,
     794+            kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight
     795+        };
     796+
     797+        // from Fonts.h
     798+        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/Font_Manager/fm_reference.pdf
     799+        OSStatus         FMCreateFontIterator(const FMFilter *iFilter, void *iRefCon, OptionBits iOptions, FMFontIterator *ioIterator);
     800+        OSStatus         FMDisposeFontIterator(FMFontIterator *ioIterator);
     801+        ATSFontFamilyRef FMGetATSFontFamilyRefFromFont(FMFontFamily iFamily);
     802+        ATSFontFamilyRef FMGetATSFontFamilyRefFromFontFamily(FMFontFamily iFamily);
     803+        ATSFontRef       FMGetATSFontRefFromFont(FMFont iFont);
     804+        OSStatus         FMGetFontFamilyInstanceFromFont(FMFont iFont, FMFontFamily *oFontFamily, FMFontStyle *oStyle);
     805+        FMFontFamily     FMGetFontFamilyFromATSFontFamilyRef(ATSFontFamilyRef iFamily);
     806+        FMFont           FMGetFontFromATSFontRef(ATSFontRef iFont);
     807+        OSStatus         FMGetFontFromFontFamilyInstance(FMFontFamily iFontFamily, FMFontStyle iStyle, FMFont *oFont, FMFontStyle *oIntrinsicStyle);
     808+        OSStatus         FMGetNextFont(FMFontIterator *ioIterator, FMFont *oFont);
     809+        enum {
     810+            kFMUseGlobalScopeOption       = 0x00000001
     811+        };
     812+        enum {
     813+            commandMark                   = 17,
     814+            checkMark                     = 18,
     815+            diamondMark                   = 19,
     816+            appleMark                     = 20
     817+        };
     818+    }
     819+#endif
     820+
     821 QT_BEGIN_NAMESPACE
     822 class QWidget;
     823 class QDragMoveEvent;
     824--- src/gui/kernel/qwidget_mac.mm.orig
     825+++ src/gui/kernel/qwidget_mac.mm
     826@@ -220,7 +220,7 @@ static QSize qt_mac_desktopSize()
     827 static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
     828 {
     829     NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->effectiveWinId());
     830-    NSArray *windows = [NSApp windows];
     831+    NSArray *windows = [[NSApplication sharedApplication] windows];
     832     for (NSWindow *window in windows) {
     833         NSArray *drawers = [window drawers];
     834         for (NSDrawer *drawer in drawers) {
     835@@ -254,7 +254,7 @@ static void qt_mac_destructWindow(OSWindowRef window)
     836 {
     837 #ifdef QT_MAC_USE_COCOA
     838     if ([window isVisible] && [window isSheet]){
     839-        [NSApp endSheet:window];
     840+        [[NSApplication sharedApplication] endSheet:window];
     841         [window orderOut:window];
     842     }
     843 
     844@@ -2439,7 +2439,7 @@ void QWidgetPrivate::recreateMacWindow()
     845     }
     846     if ([oldWindow isVisible]){
     847         if ([oldWindow isSheet])
     848-            [NSApp endSheet:oldWindow];
     849+            [[NSApplication sharedApplication] endSheet:oldWindow];
     850         [oldWindow orderOut:oldWindow];
     851         show_sys();
     852     }
     853@@ -3554,7 +3554,7 @@ void QWidgetPrivate::show_sys()
     854     }
     855 
     856 #ifdef QT_MAC_USE_COCOA
     857-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
     858+    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
     859         // Update enter/leave immidiatly, don't wait for a move event. But only
     860         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
     861         QPoint qlocal, qglobal;
     862@@ -3605,7 +3605,7 @@ void QWidgetPrivate::hide_sys()
     863             else
     864                 HideSheetWindow(window);
     865 #else
     866-            [NSApp endSheet:window];
     867+            [[NSApplication sharedApplication] endSheet:window];
     868             [window orderOut:window];
     869 #endif
     870         } else if(qt_mac_is_macdrawer(q)) {
     871@@ -3716,7 +3716,7 @@ void QWidgetPrivate::hide_sys()
     872     }
     873 
     874 #ifdef QT_MAC_USE_COCOA
     875-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
     876+    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
     877         // Update enter/leave immidiatly, don't wait for a move event. But only
     878         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
     879         QPoint qlocal, qglobal;
     880--- src/gui/styles/qmacstyle_mac.mm.orig
     881+++ src/gui/styles/qmacstyle_mac.mm
     882@@ -780,7 +780,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
     883             if (!GetThemeMenuBarHeight(&size))
     884                 ret = QSize(-1, size);
     885 #else
     886-            ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
     887+            ret = QSize(-1, [[[NSApplication sharedApplication] mainMenu] menuBarHeight]);
     888             // In the qt_mac_set_native_menubar(false) case,
     889             // we come it here with a zero-height main menu,
     890             // preventing the in-window menu from displaying.
     891@@ -3024,16 +3024,14 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
     892                 fdi.version = qt_mac_hitheme_version;
     893                 fdi.state = tds;
     894                 SInt32 frame_size;
     895-                if (pe == PE_FrameLineEdit) {
     896-                    fdi.kind = kHIThemeFrameTextFieldSquare;
     897-                    GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
     898-                    if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
     899-                        fdi.state = kThemeStateInactive;
     900-                } else {
     901-                    baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
     902-                    fdi.kind = kHIThemeFrameListBox;
     903-                    GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size);
     904-                }
     905+                fdi.kind = kHIThemeFrameTextFieldSquare;
     906+                GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
     907+                if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
     908+                    fdi.state = kThemeStateInactive;
     909+                else if (fdi.state == kThemeStatePressed)
     910+                    // This pressed state doesn't make sense for a line edit frame.
     911+                    // And Yosemite agrees with us. Otherwise it starts showing yellow pixels.
     912+                    fdi.state = kThemeStateActive;
     913                 fdi.isFocused = (frame->state & State_HasFocus);
     914                 int lw = frame->lineWidth;
     915                 if (lw <= 0)
     916--- src/gui/util/qsystemtrayicon_mac.mm.orig
     917+++ src/gui/util/qsystemtrayicon_mac.mm
     918@@ -536,7 +536,7 @@ private:
     919 #ifndef QT_MAC_USE_COCOA
     920                 const short scale = GetMBarHeight();
     921 #else
     922-                const short scale = [[NSApp mainMenu] menuBarHeight];
     923+                const short scale = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
     924 #endif
     925                 NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
     926                 [item setImage: nsimage];
     927--- src/gui/widgets/qcocoamenu_mac.mm.orig
     928+++ src/gui/widgets/qcocoamenu_mac.mm
     929@@ -202,7 +202,7 @@ QT_USE_NAMESPACE
     930      static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
     931      if (index == -1 && selForOFCP == actionSelector) {
     932          // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object
     933-         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     934+         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     935          return [super indexOfItemWithTarget:loader andAction:actionSelector];
     936      }
     937      return index;
     938--- src/gui/widgets/qmenu_mac.mm.orig
     939+++ src/gui/widgets/qmenu_mac.mm
     940@@ -179,7 +179,7 @@ static void cancelAllMenuTracking()
     941 {
     942 #ifdef QT_MAC_USE_COCOA
     943     QMacCocoaAutoReleasePool pool;
     944-    NSMenu *mainMenu = [NSApp mainMenu];
     945+    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
     946     [mainMenu cancelTracking];
     947     for (NSMenuItem *item in [mainMenu itemArray]) {
     948         if ([item submenu]) {
     949@@ -633,7 +633,7 @@ static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarP
     950 
     951 static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader()
     952 {
     953-    return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     954+    return [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
     955 }
     956 
     957 static NSMenuItem *createNSMenuItem(const QString &title)
     958@@ -2033,7 +2033,7 @@ void qt_mac_clear_menubar()
     959     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     960     NSMenu *menu = [loader menu];
     961     [loader ensureAppMenuInMenu:menu];
     962-    [NSApp setMainMenu:menu];
     963+    [[NSApplication sharedApplication] setMainMenu:menu];
     964     const bool modal = qt_mac_should_disable_menu(0);
     965     if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
     966         qt_mac_set_modal_state(menu, modal);
     967@@ -2100,7 +2100,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
     968 #else
     969             QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     970             [loader ensureAppMenuInMenu:menu];
     971-            [NSApp setMainMenu:menu];
     972+            [[NSApplication sharedApplication] setMainMenu:menu];
     973             syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
     974 
     975             if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
     976@@ -2140,7 +2140,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
     977 #else
     978                 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
     979                 [loader ensureAppMenuInMenu:menu];
     980-                [NSApp setMainMenu:menu];
     981+                [[NSApplication sharedApplication] setMainMenu:menu];
     982                 syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar);
     983 #endif
     984                 qt_mac_set_modal_state(menu, modal);