[126865] trunk/dports/aqua/qt4-mac

michaelld at macports.org michaelld at macports.org
Thu Oct 16 11:19:17 PDT 2014


Revision: 126865
          https://trac.macports.org/changeset/126865
Author:   michaelld at macports.org
Date:     2014-10-16 11:19:17 -0700 (Thu, 16 Oct 2014)
Log Message:
-----------
qt4-mac: minimal update for Yosimite (10.10); no rev-bump necessary.  Addresses ticket #44017.

Modified Paths:
--------------
    trunk/dports/aqua/qt4-mac/Portfile

Added Paths:
-----------
    trunk/dports/aqua/qt4-mac/files/patch-10.10.diff

Modified: trunk/dports/aqua/qt4-mac/Portfile
===================================================================
--- trunk/dports/aqua/qt4-mac/Portfile	2014-10-16 18:16:23 UTC (rev 126864)
+++ trunk/dports/aqua/qt4-mac/Portfile	2014-10-16 18:19:17 UTC (rev 126865)
@@ -240,15 +240,20 @@
 patchfiles-append   \
     patch-tools_macdeployqt_shared_shared.cpp.diff
 
-# error out if trying to build on a new OSX version (> 10.9).
+# (24) minimum patches required for 10.10; squashed; temporary until 4.8.7.
 
+patchfiles-append   \
+    patch-10.10.diff
+
+# error out if trying to build on a new OSX version (> 10.10).
+
 platform darwin {
-    if {${MINOR} > 9} {
+    if {${MINOR} > 10} {
         # This project needs to be updated to build with clang++ against libc++
         depends_lib
         depends_run
         pre-fetch {
-            ui_error "$name does not currently build on OSX later than 10.9 'Mavericks'."
+            ui_error "$name does not currently build on OSX later than 10.10 'Yosemite'."
             error "unsupported platform"
         }
     }

Added: trunk/dports/aqua/qt4-mac/files/patch-10.10.diff
===================================================================
--- trunk/dports/aqua/qt4-mac/files/patch-10.10.diff	                        (rev 0)
+++ trunk/dports/aqua/qt4-mac/files/patch-10.10.diff	2014-10-16 18:19:17 UTC (rev 126865)
@@ -0,0 +1,1968 @@
+--- src/corelib/global/qglobal.cpp.orig
++++ src/corelib/global/qglobal.cpp
+@@ -1185,6 +1185,7 @@ bool qSharedBuild()
+     \value MV_10_7     OS X 10.7
+     \value MV_10_8     OS X 10.8
+     \value MV_10_9     OS X 10.9
++    \value MV_10_10    OS X 10.10
+     \value MV_Unknown  An unknown and currently unsupported platform
+ 
+     \value MV_CHEETAH  Apple codename for MV_10_0
+@@ -1197,6 +1198,7 @@ bool qSharedBuild()
+     \value MV_LION     Apple codename for MV_10_7
+     \value MV_MOUNTAINLION Apple codename for MV_10_8
+     \value MV_MAVERICKS    Apple codename for MV_10_9
++    \value MV_YOSEMITE     Apple codename for MV_10_10
+ 
+     \sa WinVersion, SymbianVersion
+ */
+@@ -1674,8 +1676,9 @@ static QSysInfo::MacVersion macVersion()
+ {
+ #if !defined(Q_OS_IOS)
+     SInt32 gestalt_version;
+-    if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
+-        return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
++    if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) {
++        // add 2 because OS X 10.0 is 0x02 in the enum
++        return QSysInfo::MacVersion(gestalt_version + 2);
+     }
+ #endif
+     return QSysInfo::MV_Unknown;
+--- src/corelib/global/qglobal.h.orig
++++ src/corelib/global/qglobal.h
+@@ -304,31 +304,69 @@ namespace QT_NAMESPACE {}
+ #endif
+ 
+ #ifdef Q_OS_DARWIN
+-#  ifdef MAC_OS_X_VERSION_MIN_REQUIRED
+-#    undef MAC_OS_X_VERSION_MIN_REQUIRED
+-#  endif
+-#  define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
+ #  include <AvailabilityMacros.h>
+-#  if !defined(MAC_OS_X_VERSION_10_3)
+-#     define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1
++#
++#  // Availability.h was introduced with the OS X 10.6 SDK
++#  if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060) || \
++      (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
++#    include <Availability.h>
++#  endif
++#
++#  ifdef Q_OS_MACX
++#    if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < 1040
++#       undef __MAC_OS_X_VERSION_MIN_REQUIRED
++#       define __MAC_OS_X_VERSION_MIN_REQUIRED 1040
++#    endif
++#    if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < 1040
++#       undef MAC_OS_X_VERSION_MIN_REQUIRED
++#       define MAC_OS_X_VERSION_MIN_REQUIRED 1040
++#    endif
++#  endif
++#
++#  // Numerical checks are preferred to named checks, but to be safe
++#  // we define the missing version names in case Qt uses them.
++#
++#  if !defined(__MAC_10_4)
++#       define __MAC_10_4 1040
++#  endif
++#  if !defined(__MAC_10_5)
++#       define __MAC_10_5 1050
++#  endif
++#  if !defined(__MAC_10_6)
++#       define __MAC_10_6 1060
++#  endif
++#  if !defined(__MAC_10_7)
++#       define __MAC_10_7 1070
++#  endif
++#  if !defined(__MAC_10_8)
++#       define __MAC_10_8 1080
++#  endif
++#  if !defined(__MAC_10_9)
++#       define __MAC_10_9 1090
++#  endif
++#  if !defined(__MAC_10_10)
++#       define __MAC_10_10 101000
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_4)
+-#       define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1
++#       define MAC_OS_X_VERSION_10_4 1040
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_5)
+-#       define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1
++#       define MAC_OS_X_VERSION_10_5 1050
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_6)
+-#       define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
++#       define MAC_OS_X_VERSION_10_6 1060
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_7)
+-#       define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1
++#       define MAC_OS_X_VERSION_10_7 1070
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_8)
+-#       define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1
++#       define MAC_OS_X_VERSION_10_8 1080
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_9)
+-#       define MAC_OS_X_VERSION_10_9 MAC_OS_X_VERSION_10_8 + 1
++#       define MAC_OS_X_VERSION_10_9 1090
++#  endif
++#  if !defined(MAC_OS_X_VERSION_10_10)
++#       define MAC_OS_X_VERSION_10_10 101000
+ #  endif
+ #endif
+ 
+@@ -1630,6 +1668,7 @@ public:
+         MV_10_7 = 0x0009,
+         MV_10_8 = 0x000A,
+         MV_10_9 = 0x000B,
++        MV_10_10 = 0x000C,
+ 
+         /* codenames */
+         MV_CHEETAH = MV_10_0,
+@@ -1641,7 +1680,8 @@ public:
+         MV_SNOWLEOPARD = MV_10_6,
+         MV_LION = MV_10_7,
+         MV_MOUNTAINLION = MV_10_8,
+-        MV_MAVERICKS = MV_10_9
++        MV_MAVERICKS = MV_10_9,
++        MV_YOSEMITE = MV_10_10
+     };
+     static const MacVersion MacintoshVersion;
+ #endif
+--- src/gui/dialogs/qcolordialog_mac.mm.orig
++++ src/gui/dialogs/qcolordialog_mac.mm
+@@ -318,7 +318,7 @@ QT_USE_NAMESPACE
+         // It's important that the modal event loop is stopped before
+         // we accept/reject QColorDialog, since QColorDialog has its
+         // own event loop that needs to be stopped last. 
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         // Since we are not in a modal event loop, we can safely close
+         // down QColorDialog
+@@ -350,7 +350,7 @@ QT_USE_NAMESPACE
+     while (!modalEnded) {
+ #ifndef QT_NO_EXCEPTIONS
+         @try {
+-            [NSApp runModalForWindow:mColorPanel];
++            [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
+             modalEnded = true;
+         } @catch (NSException *) {
+             // For some reason, NSColorPanel throws an exception when
+@@ -358,7 +358,7 @@ QT_USE_NAMESPACE
+             // palette (tab three).
+         }
+ #else
+-        [NSApp runModalForWindow:mColorPanel];
++        [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
+         modalEnded = true;
+ #endif
+     }
+@@ -469,10 +469,10 @@ void QColorDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (delegate){
+         Q_Q(QColorDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/dialogs/qfiledialog_mac.mm.orig
++++ src/gui/dialogs/qfiledialog_mac.mm
+@@ -229,7 +229,7 @@ QT_USE_NAMESPACE
+     if ([mSavePanel respondsToSelector:@selector(close)])
+         [mSavePanel close];
+     if ([mSavePanel isSheet])
+-        [NSApp endSheet: mSavePanel];
++        [[NSApplication sharedApplication] endSheet: mSavePanel];
+ }
+ 
+ - (void)showModelessPanel
+@@ -1162,10 +1162,10 @@ void QFileDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (nativeDialogInUse){
+         Q_Q(QFileDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/dialogs/qfontdialog_mac.mm.orig
++++ src/gui/dialogs/qfontdialog_mac.mm
+@@ -230,7 +230,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+     mAppModal = true;
+     NSWindow *ourPanel = [mStolenContentView window];
+     [ourPanel setReleasedWhenClosed:NO];
+-    [NSApp runModalForWindow:ourPanel];
++    [[NSApplication sharedApplication] runModalForWindow:ourPanel];
+     QAbstractEventDispatcher::instance()->interrupt();
+ 
+     if (mReturnCode == NSOKButton)
+@@ -256,7 +256,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+ 
+     mAppModal = false;
+     NSWindow *ourPanel = [mStolenContentView window];
+-    [NSApp beginSheet:ourPanel
++    [[NSApplication sharedApplication] beginSheet:ourPanel
+         modalForWindow:window
+         modalDelegate:0
+         didEndSelector:0
+@@ -456,7 +456,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+ 
+     if (mAppModal) {
+         mReturnCode = code;
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         if (code == NSOKButton)
+             mPriv->fontDialog()->accept();
+@@ -636,10 +636,10 @@ void QFontDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (nativeDialogInUse) {
+         Q_Q(QFontDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/kernel/qapplication_mac.mm.orig
++++ src/gui/kernel/qapplication_mac.mm
+@@ -468,7 +468,7 @@ void qt_mac_set_app_icon(const QPixmap &pixmap)
+         image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
+     }
+ 
+-    [NSApp setApplicationIconImage:image];
++    [[NSApplication sharedApplication] setApplicationIconImage:image];
+     [image release];
+ #endif
+ }
+@@ -750,7 +750,7 @@ void qt_event_request_showsheet(QWidget *w)
+     Q_ASSERT(qt_mac_is_macsheet(w));
+ #ifdef QT_MAC_USE_COCOA
+     w->repaint();
+-    [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
++    [[NSApplication sharedApplication] beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
+         modalDelegate:nil didEndSelector:nil contextInfo:0];
+ #else
+     qt_mac_event_remove(request_showsheet_pending);
+@@ -992,7 +992,7 @@ Q_GUI_EXPORT void qt_mac_set_dock_menu(QMenu *menu)
+ {
+     qt_mac_dock_menu = menu;
+ #ifdef QT_MAC_USE_COCOA
+-    [NSApp setDockMenu:menu->macMenu()];
++    [[NSApplication sharedApplication] setDockMenu:menu->macMenu()];
+ #else
+     SetApplicationDockTileMenu(menu->macMenu());
+ #endif
+@@ -1011,7 +1011,7 @@ void qt_mac_event_release(QWidget *w)
+ #ifndef QT_MAC_USE_COCOA
+             SetApplicationDockTileMenu(0);
+ #else
+-            [NSApp setDockMenu:0];
++            [[NSApplication sharedApplication] setDockMenu:0];
+ #endif
+         }
+     }
+@@ -1463,7 +1463,7 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
+     NSWindowList(windowCount, windowList.data());
+     int firstQtWindowFound = -1;
+     for (int i = 0; i < windowCount; ++i) {
+-        NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
++        NSWindow *window = [[NSApplication sharedApplication] windowWithWindowNumber:windowList[i]];
+         if (window) {
+             QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
+             if (candidateWindow && firstQtWindowFound == -1)
+@@ -3071,7 +3071,7 @@ bool QApplicationPrivate::canQuit()
+ #else
+     Q_Q(QApplication);
+ #ifdef QT_MAC_USE_COCOA
+-    [[NSApp mainMenu] cancelTracking];
++    [[[NSApplication sharedApplication] mainMenu] cancelTracking];
+ #else
+     HiliteMenu(0);
+ #endif
+@@ -3146,7 +3146,7 @@ void onApplicationChangedActivation( bool activated )
+         }
+ 
+         if (!app->activeWindow()) {
+-            OSWindowRef wp = [NSApp keyWindow];
++            OSWindowRef wp = [[NSApplication sharedApplication] keyWindow];
+             if (QWidget *tmp_w = qt_mac_find_window(wp))
+                 app->setActiveWindow(tmp_w);
+         }
+--- src/gui/kernel/qcocoaapplication_mac.mm.orig
++++ src/gui/kernel/qcocoaapplication_mac.mm
+@@ -147,7 +147,7 @@ QT_USE_NAMESPACE
+     if ([event type] == NSApplicationDefined) {
+         switch ([event subtype]) {
+             case QtCocoaEventSubTypePostMessage:
+-                [NSApp QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
++                [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
+                 return true;
+             default:
+                 break;
+@@ -174,7 +174,7 @@ QT_USE_NAMESPACE
+     // be called instead of sendEvent if redirection occurs.
+     // 'self' will then be an instance of NSApplication
+     // (and not QNSApplication)
+-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
++    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+         [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
+ }
+ 
+@@ -182,7 +182,7 @@ QT_USE_NAMESPACE
+ {
+     // This method will be called if
+     // no redirection occurs
+-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
++    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+         [super sendEvent:event];
+ }
+ 
+@@ -194,7 +194,7 @@ QT_USE_NAMESPACE
+     // visible on screen. Note: If Qt is used as a plugin, Qt will not use a 
+     // native menu bar. Hence, we will also not need to do any redirection etc. as 
+     // we do with sendEvent.
+-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
++    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+ }
+ 
+ @end
+@@ -203,7 +203,7 @@ QT_BEGIN_NAMESPACE
+ 
+ void qt_redirectNSApplicationSendEvent()
+ {
+-    if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
++    if ([[NSApplication sharedApplication] isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
+         // No need to change implementation since Qt
+         // already controls a subclass of NSApplication
+         return;
+--- src/gui/kernel/qcocoaapplicationdelegate_mac.mm.orig
++++ src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+@@ -122,7 +122,7 @@ static void cleanupCocoaApplicationDelegate()
+     [dockMenu release];
+     [qtMenuLoader release];
+     if (reflectionDelegate) {
+-        [NSApp setDelegate:reflectionDelegate];
++        [[NSApplication sharedApplication] setDelegate:reflectionDelegate];
+         [reflectionDelegate release];
+     }
+     [super dealloc];
+@@ -183,7 +183,7 @@ static void cleanupCocoaApplicationDelegate()
+     return [[qtMenuLoader retain] autorelease];
+ }
+ 
+-// This function will only be called when NSApp is actually running. Before
++// This function will only be called when NSApplication is actually running. Before
+ // that, the kAEQuitApplication Apple event will be sent to
+ // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
+ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+@@ -249,7 +249,7 @@ static void cleanupCocoaApplicationDelegate()
+         && [reflectionDelegate respondsToSelector:
+                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
+         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
+-    return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
++    return NO; // Someday qApp->quitOnLastWindowClosed(); when qApp and NSApplication work closer together.
+ }
+ 
+ 
+@@ -289,13 +289,26 @@ static void cleanupCocoaApplicationDelegate()
+     qt_button_down = 0;
+ }
+ 
++- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
++{
++    Q_UNUSED(theApplication);
++    Q_UNUSED(flag);
++    // The reflection delegate gets precedence
++    if (reflectionDelegate
++        && [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
++        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
++
++    onApplicationChangedActivation(true);
++    return NO;
++}
++
+ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
+ {
+     Q_UNUSED(notification);
+     QDesktopWidgetImplementation::instance()->onResize();
+ }
+ 
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate
+ {
+     [oldDelegate retain];
+     [reflectionDelegate release];
+@@ -342,12 +355,12 @@ static void cleanupCocoaApplicationDelegate()
+ {
+     Q_UNUSED(event);
+     Q_UNUSED(replyEvent);
+-    [NSApp terminate:self];
++    [[NSApplication sharedApplication] terminate:self];
+ }
+ 
+ - (void)qtDispatcherToQAction:(id)sender
+ {
+-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
++    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+ }
+ 
+ @end
+--- src/gui/kernel/qcocoaapplicationdelegate_mac_p.h.orig
++++ src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+@@ -113,7 +113,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
+     QApplicationPrivate *qtPrivate;
+     NSMenu *dockMenu;
+     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
+-    NSObject <NSApplicationDelegate> *reflectionDelegate;
++    id <NSApplicationDelegate> reflectionDelegate;
+     bool inLaunch;
+ }
+ + (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
+@@ -122,7 +122,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
+ - (QApplicationPrivate *)qAppPrivate;
+ - (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
+ - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate;
+ - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
+ @end
+ #endif
+--- src/gui/kernel/qcocoamenuloader_mac.mm.orig
++++ src/gui/kernel/qcocoamenuloader_mac.mm
+@@ -92,8 +92,8 @@ QT_USE_NAMESPACE
+     // 'Quit' item. When changing menu bar (e.g when switching between
+     // windows with different menu bars), we never recreate this menu, but
+     // instead pull it out the current menu bar and place into the new one:
+-    NSMenu *mainMenu = [NSApp mainMenu];
+-    if ([NSApp mainMenu] == menu)
++    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
++    if ([[NSApplication sharedApplication] mainMenu] == menu)
+         return; // nothing to do (menu is the current menu bar)!
+ 
+ #ifndef QT_NAMESPACE
+@@ -201,27 +201,27 @@ QT_USE_NAMESPACE
+ 
+ - (void)terminate:(id)sender
+ {
+-    [NSApp terminate:sender];
++    [[NSApplication sharedApplication] terminate:sender];
+ }
+ 
+ - (void)orderFrontStandardAboutPanel:(id)sender
+ {
+-    [NSApp orderFrontStandardAboutPanel:sender];
++    [[NSApplication sharedApplication] orderFrontStandardAboutPanel:sender];
+ }
+ 
+ - (void)hideOtherApplications:(id)sender
+ {
+-    [NSApp hideOtherApplications:sender];
++    [[NSApplication sharedApplication] hideOtherApplications:sender];
+ }
+ 
+ - (void)unhideAllApplications:(id)sender
+ {
+-    [NSApp unhideAllApplications:sender];
++    [[NSApplication sharedApplication] unhideAllApplications:sender];
+ }
+ 
+ - (void)hide:(id)sender
+ {
+-    [NSApp hide:sender];
++    [[NSApplication sharedApplication] hide:sender];
+ }
+ 
+ - (void)qtUpdateMenubar
+@@ -258,7 +258,7 @@ QT_USE_NAMESPACE
+ 
+  - (void)orderFrontCharacterPalette:(id)sender
+  {
+-     [NSApp orderFrontCharacterPalette:sender];
++     [[NSApplication sharedApplication] orderFrontCharacterPalette:sender];
+  }
+ 
+ - (BOOL)validateMenuItem:(NSMenuItem*)menuItem
+@@ -266,7 +266,7 @@ QT_USE_NAMESPACE
+     if ([menuItem action] == @selector(hide:)
+         || [menuItem action] == @selector(hideOtherApplications:)
+         || [menuItem action] == @selector(unhideAllApplications:)) {
+-        return [NSApp validateMenuItem:menuItem];
++        return [[NSApplication sharedApplication] validateMenuItem:menuItem];
+     } else {
+         return [menuItem isEnabled];
+     }
+--- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h.orig
++++ src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+@@ -143,7 +143,7 @@ QT_END_NAMESPACE
+ {
+     // This function is called from the quit item in the menubar when this window
+     // is in the first responder chain (see also qtDispatcherToQAction above)
+-    [NSApp terminate:sender];
++    [[NSApplication sharedApplication] terminate:sender];
+ }
+ 
+ - (void)setLevel:(NSInteger)windowLevel
+@@ -364,7 +364,7 @@ QT_END_NAMESPACE
+ 
+     if ([sender draggingSource] != nil) {
+         // modifier flags might have changed, update it here since we don't send any input events.
+-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
++        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
+         modifiers = QApplication::keyboardModifiers();
+     } else {
+         // when the source is from another application the above technique will not work.
+@@ -456,7 +456,7 @@ QT_END_NAMESPACE
+ 
+     // Update modifiers:
+     if ([sender draggingSource] != nil) {
+-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
++        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
+         modifiers = QApplication::keyboardModifiers();
+     } else {
+         modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+--- src/gui/kernel/qeventdispatcher_mac.mm.orig
++++ src/gui/kernel/qeventdispatcher_mac.mm
+@@ -461,7 +461,7 @@ static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event,
+     if (pt)
+         [pt sendEvent:event];
+     else
+-        [NSApp sendEvent:event];
++        [[NSApplication sharedApplication] sendEvent:event];
+     return true;
+ #endif
+ }
+@@ -521,12 +521,12 @@ static inline void qt_mac_waitForMoreEvents()
+     // (and free up cpu time) until at least one event occur.
+     // This implementation is a bit on the edge, but seems to
+     // work fine:
+-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
++    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+         untilDate:[NSDate distantFuture]
+         inMode:NSDefaultRunLoopMode
+         dequeue:YES];
+     if (event)
+-        [NSApp postEvent:event atStart:YES];
++        [[NSApplication sharedApplication] postEvent:event atStart:YES];
+ #endif
+ }
+ 
+@@ -537,12 +537,12 @@ static inline void qt_mac_waitForMoreModalSessionEvents()
+     // (and free up cpu time) until at least one event occur.
+     // This implementation is a bit on the edge, but seems to
+     // work fine:
+-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
++    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+         untilDate:[NSDate distantFuture]
+         inMode:NSModalPanelRunLoopMode
+         dequeue:YES];
+     if (event)
+-        [NSApp postEvent:event atStart:YES];
++        [[NSApplication sharedApplication] postEvent:event atStart:YES];
+ }
+ #endif
+ 
+@@ -588,23 +588,23 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+         // done from the application itself. And if processEvents is called
+         // manually (rather than from a QEventLoop), we cannot enter a tight
+         // loop and block this call, but instead we need to return after one flush.
+-        // Finally, if we are to exclude user input events, we cannot call [NSApp run]
++        // Finally, if we are to exclude user input events, we cannot call [NSApplication run]
+         // as we then loose control over which events gets dispatched:
+-        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
++        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![[NSApplication sharedApplication] isRunning];
+         const bool canExec_Qt = !excludeUserEvents &&
+                 (flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec) ;
+ 
+         if (canExec_Qt && canExec_3rdParty) {
+             // We can use exec-mode, meaning that we can stay in a tight loop until
+             // interrupted. This is mostly an optimization, but it allow us to use
+-            // [NSApp run], which is the normal code path for cocoa applications.
++            // [NSApplication run], which is the normal code path for cocoa applications.
+             if (NSModalSession session = d->currentModalSession()) {
+                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
+-                while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
++                while ([[NSApplication sharedApplication] runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
+                     qt_mac_waitForMoreModalSessionEvents();
+ 
+                 if (!d->interrupt && session == d->currentModalSessionCached) {
+-                    // Someone called [NSApp stopModal:] from outside the event
++                    // Someone called [[NSApplication sharedApplication] stopModal:] from outside the event
+                     // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+                     // 'session' as well. As a result, we need to restart all internal sessions:
+                     d->temporarilyStopAllModalSessions();
+@@ -612,7 +612,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+             } else {
+                 d->nsAppRunCalledByQt = true;
+                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
+-                [NSApp run];
++                [[NSApplication sharedApplication] run];
+             }
+             retVal = true;
+         } else {
+@@ -626,9 +626,9 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                     // to use cocoa's native way of running modal sessions:
+                     if (flags & QEventLoop::WaitForMoreEvents)
+                         qt_mac_waitForMoreModalSessionEvents();
+-                    NSInteger status = [NSApp runModalSession:session];
++                    NSInteger status = [[NSApplication sharedApplication] runModalSession:session];
+                     if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+-                        // INVARIANT: Someone called [NSApp stopModal:] from outside the event
++                        // INVARIANT: Someone called [NSApplication stopModal:] from outside the event
+                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+                         // 'session' as well. As a result, we need to restart all internal sessions:
+                         d->temporarilyStopAllModalSessions();
+@@ -637,8 +637,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                 } else do {
+                     // Dispatch all non-user events (but que non-user events up for later). In
+                     // this case, we need more control over which events gets dispatched, and
+-                    // cannot use [NSApp runModalSession:session]:
+-                    event = [NSApp nextEventMatchingMask:NSAnyEventMask
++                    // cannot use [NSApplication runModalSession:session]:
++                    event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+                     untilDate:nil
+                     inMode:NSModalPanelRunLoopMode
+                     dequeue: YES];
+@@ -655,7 +655,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                 } while (!d->interrupt && event != nil);
+             } else do {
+                 // INVARIANT: No modal window is executing.
+-                event = [NSApp nextEventMatchingMask:NSAnyEventMask
++                event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+                 untilDate:nil
+                 inMode:NSDefaultRunLoopMode
+                 dequeue: YES];
+@@ -798,12 +798,12 @@ void QEventDispatcherMacPrivate::ensureNSAppInitialized()
+     // we let Cocoa finish the initialization it seems to need. We'll only
+     // apply this trick at most once for any application, and we avoid doing it
+     // for the common case where main just starts QApplication::exec.
+-    if (nsAppRunCalledByQt || [NSApp isRunning])
++    if (nsAppRunCalledByQt || [[NSApplication sharedApplication] isRunning])
+         return;
+     nsAppRunCalledByQt = true;
+     QBoolBlocker block1(interrupt, true);
+     QBoolBlocker block2(currentExecIsNSAppRun, true);
+-    [NSApp run];
++    [[NSApplication sharedApplication] run];
+ }
+ 
+ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+@@ -812,8 +812,8 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+     // such, make them pending again. The next call to
+     // currentModalSession will recreate them again. The
+     // reason to stop all session like this is that otherwise
+-    // a call [NSApp stop] would not stop NSApp, but rather
+-    // the current modal session. So if we need to stop NSApp
++    // a call [NSApplication stop] would not stop NSApplication, but rather
++    // the current modal session. So if we need to stop NSApplication
+     // we need to stop all the modal session first. To avoid changing
+     // the stacking order of the windows while doing so, we put
+     // up a block that is used in QCocoaWindow and QCocoaPanel:
+@@ -821,7 +821,7 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+     for (int i=0; i<stackSize; ++i) {
+         QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+         if (info.session) {
+-            [NSApp endModalSession:info.session];
++            [[NSApplication sharedApplication] endModalSession:info.session];
+             info.session = 0;
+         }
+     }
+@@ -856,7 +856,7 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
+             info.nswindow = window;
+             [(NSWindow*) info.nswindow retain];
+             int levelBeforeEnterModal = [window level];
+-            info.session = [NSApp beginModalSessionForWindow:window];
++            info.session = [[NSApplication sharedApplication] beginModalSessionForWindow:window];
+             // Make sure we don't stack the window lower that it was before
+             // entering modal, in case it e.g. had the stays-on-top flag set:
+             if (levelBeforeEnterModal > [window level])
+@@ -926,7 +926,7 @@ void QEventDispatcherMacPrivate::cleanupModalSessions()
+         cocoaModalSessionStack.remove(i);
+         currentModalSessionCached = 0;
+         if (info.session) {
+-            [NSApp endModalSession:info.session];
++            [[NSApplication sharedApplication] endModalSession:info.session];
+             [(NSWindow *)info.nswindow release];
+         }
+     }
+@@ -1057,7 +1057,7 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
+             // pending cocoa events first).
+             if (d->currentModalSessionCached)
+                 d->temporarilyStopAllModalSessions();
+-            [NSApp stop:NSApp];
++            [[NSApplication sharedApplication] stop:[NSApplication sharedApplication]];
+             d->cancelWaitForMoreEvents();
+         }
+ #endif
+@@ -1093,7 +1093,8 @@ void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
+     // In case the event dispatcher is waiting for more
+     // events somewhere, we post a dummy event to wake it up:
+     QMacCocoaAutoReleasePool pool;
+-    [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
++    [[NSApplication sharedApplication] postEvent:[NSEvent otherEventWithType:NSApplicationDefined
++        location:NSZeroPoint
+         modifierFlags:0 timestamp:0. windowNumber:0 context:0
+         subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
+ }
+@@ -1110,7 +1111,7 @@ void QEventDispatcherMac::interrupt()
+ #else
+     // We do nothing more here than setting d->interrupt = true, and
+     // poke the event loop if it is sleeping. Actually stopping
+-    // NSApp, or the current modal session, is done inside the send
++    // NSApplication, or the current modal session, is done inside the send
+     // posted events callback. We do this to ensure that all current pending
+     // cocoa events gets delivered before we stop. Otherwise, if we now stop
+     // the last event loop recursion, cocoa will just drop pending posted
+@@ -1165,7 +1166,7 @@ QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false)
+     // The whole point of this class is that we enable a way to interrupt
+     // the event dispatcher when returning back to a lower recursion level
+     // than where interruptLater was called. This is needed to detect if
+-    // [NSApp run] should still be running at the recursion level it is at.
++    // [NSApplication run] should still be running at the recursion level it is at.
+     // Since the interrupt is canceled if processEvents is called before
+     // this object gets deleted, we also avoid interrupting unnecessary.
+     deleteLater();
+--- src/gui/kernel/qt_cocoa_helpers_mac.mm.orig
++++ src/gui/kernel/qt_cocoa_helpers_mac.mm
+@@ -1697,7 +1697,7 @@ void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2
+     NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
+         location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
+         context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
+-    [NSApp postEvent:e atStart:NO];
++    [[NSApplication sharedApplication] postEvent:e atStart:NO];
+ }
+ 
+ void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount, id arg1, id arg2)
+@@ -1727,7 +1727,7 @@ void qt_mac_post_retranslateAppMenu()
+ {
+ #ifdef QT_MAC_USE_COCOA
+     QMacCocoaAutoReleasePool pool;
+-    qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
++    qt_cocoaPostMessage([[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
+ #endif
+ }
+ 
+--- src/gui/kernel/qt_mac_p.h.orig
++++ src/gui/kernel/qt_mac_p.h
+@@ -75,6 +75,62 @@
+ 
+ #include <Carbon/Carbon.h>
+ 
++#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
++    // Some deprecated functions have been removed from the the 10.7 SDK, but the symbols are
++    // still exported by the 32-bit QD.framework (a subframework of ApplicationServices).
++    extern "C" {
++        // from QuickdrawAPI.h
++        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/QuickDraw_Ref/QuickDraw_Ref.pdf
++        void          CopyBits(const BitMap *srcBits, const BitMap *dstBits, const Rect *srcRect, const Rect *dstRect, short mode, RgnHandle maskRgn);
++        void          CopyRgn(RgnHandle srcRgn, RgnHandle dstRgn);
++        void          DisposeRgn(RgnHandle rgn);
++        GDHandle      GetMainDevice(void);
++        const BitMap *GetPortBitMapForCopyBits(CGrafPtr port);
++        Rect         *GetRegionBounds(RgnHandle region, Rect *bounds);
++        RgnHandle     NewRgn(void);
++        OSStatus      QDRegionToRects(RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void *userData);
++        void          SetEmptyRgn(RgnHandle rgn);
++        void          SetRect(Rect* r, short left, short top, short right, short bottom);
++        void          SetRectRgn(RgnHandle rgn, short left, short top, short right, short bottom);
++        void          UnionRgn(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
++        enum {
++            kQDRegionToRectsMsgInit       = 1,
++            kQDRegionToRectsMsgParse      = 2,
++            kQDRegionToRectsMsgTerminate  = 3
++        };
++        enum {
++            kQDParseRegionFromTop         = (1 << 0),
++            kQDParseRegionFromBottom      = (1 << 1),
++            kQDParseRegionFromLeft        = (1 << 2),
++            kQDParseRegionFromRight       = (1 << 3),
++            kQDParseRegionFromTopLeft     = kQDParseRegionFromTop | kQDParseRegionFromLeft,
++            kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight
++        };
++
++        // from Fonts.h
++        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/Font_Manager/fm_reference.pdf
++        OSStatus         FMCreateFontIterator(const FMFilter *iFilter, void *iRefCon, OptionBits iOptions, FMFontIterator *ioIterator);
++        OSStatus         FMDisposeFontIterator(FMFontIterator *ioIterator);
++        ATSFontFamilyRef FMGetATSFontFamilyRefFromFont(FMFontFamily iFamily);
++        ATSFontFamilyRef FMGetATSFontFamilyRefFromFontFamily(FMFontFamily iFamily);
++        ATSFontRef       FMGetATSFontRefFromFont(FMFont iFont);
++        OSStatus         FMGetFontFamilyInstanceFromFont(FMFont iFont, FMFontFamily *oFontFamily, FMFontStyle *oStyle);
++        FMFontFamily     FMGetFontFamilyFromATSFontFamilyRef(ATSFontFamilyRef iFamily);
++        FMFont           FMGetFontFromATSFontRef(ATSFontRef iFont);
++        OSStatus         FMGetFontFromFontFamilyInstance(FMFontFamily iFontFamily, FMFontStyle iStyle, FMFont *oFont, FMFontStyle *oIntrinsicStyle);
++        OSStatus         FMGetNextFont(FMFontIterator *ioIterator, FMFont *oFont);
++        enum {
++            kFMUseGlobalScopeOption       = 0x00000001
++        };
++        enum {
++            commandMark                   = 17,
++            checkMark                     = 18,
++            diamondMark                   = 19,
++            appleMark                     = 20
++        };
++    }
++#endif
++
+ QT_BEGIN_NAMESPACE
+ class QWidget;
+ class QDragMoveEvent;
+--- src/gui/kernel/qwidget_mac.mm.orig
++++ src/gui/kernel/qwidget_mac.mm
+@@ -220,7 +220,7 @@ static QSize qt_mac_desktopSize()
+ static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
+ {
+     NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->effectiveWinId());
+-    NSArray *windows = [NSApp windows];
++    NSArray *windows = [[NSApplication sharedApplication] windows];
+     for (NSWindow *window in windows) {
+         NSArray *drawers = [window drawers];
+         for (NSDrawer *drawer in drawers) {
+@@ -254,7 +254,7 @@ static void qt_mac_destructWindow(OSWindowRef window)
+ {
+ #ifdef QT_MAC_USE_COCOA
+     if ([window isVisible] && [window isSheet]){
+-        [NSApp endSheet:window];
++        [[NSApplication sharedApplication] endSheet:window];
+         [window orderOut:window];
+     }
+ 
+@@ -2439,7 +2439,7 @@ void QWidgetPrivate::recreateMacWindow()
+     }
+     if ([oldWindow isVisible]){
+         if ([oldWindow isSheet])
+-            [NSApp endSheet:oldWindow];
++            [[NSApplication sharedApplication] endSheet:oldWindow];
+         [oldWindow orderOut:oldWindow];
+         show_sys();
+     }
+@@ -3554,7 +3554,7 @@ void QWidgetPrivate::show_sys()
+     }
+ 
+ #ifdef QT_MAC_USE_COCOA
+-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+         // Update enter/leave immidiatly, don't wait for a move event. But only
+         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+         QPoint qlocal, qglobal;
+@@ -3605,7 +3605,7 @@ void QWidgetPrivate::hide_sys()
+             else
+                 HideSheetWindow(window);
+ #else
+-            [NSApp endSheet:window];
++            [[NSApplication sharedApplication] endSheet:window];
+             [window orderOut:window];
+ #endif
+         } else if(qt_mac_is_macdrawer(q)) {
+@@ -3716,7 +3716,7 @@ void QWidgetPrivate::hide_sys()
+     }
+ 
+ #ifdef QT_MAC_USE_COCOA
+-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+         // Update enter/leave immidiatly, don't wait for a move event. But only
+         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+         QPoint qlocal, qglobal;
+--- src/gui/styles/qmacstyle_mac.mm.orig
++++ src/gui/styles/qmacstyle_mac.mm
+@@ -780,7 +780,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
+             if (!GetThemeMenuBarHeight(&size))
+                 ret = QSize(-1, size);
+ #else
+-            ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
++            ret = QSize(-1, [[[NSApplication sharedApplication] mainMenu] menuBarHeight]);
+             // In the qt_mac_set_native_menubar(false) case,
+             // we come it here with a zero-height main menu,
+             // preventing the in-window menu from displaying.
+@@ -3024,16 +3024,14 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
+                 fdi.version = qt_mac_hitheme_version;
+                 fdi.state = tds;
+                 SInt32 frame_size;
+-                if (pe == PE_FrameLineEdit) {
+-                    fdi.kind = kHIThemeFrameTextFieldSquare;
+-                    GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
+-                    if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
+-                        fdi.state = kThemeStateInactive;
+-                } else {
+-                    baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
+-                    fdi.kind = kHIThemeFrameListBox;
+-                    GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size);
+-                }
++                fdi.kind = kHIThemeFrameTextFieldSquare;
++                GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
++                if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
++                    fdi.state = kThemeStateInactive;
++                else if (fdi.state == kThemeStatePressed)
++                    // This pressed state doesn't make sense for a line edit frame.
++                    // And Yosemite agrees with us. Otherwise it starts showing yellow pixels.
++                    fdi.state = kThemeStateActive;
+                 fdi.isFocused = (frame->state & State_HasFocus);
+                 int lw = frame->lineWidth;
+                 if (lw <= 0)
+--- src/gui/util/qsystemtrayicon_mac.mm.orig
++++ src/gui/util/qsystemtrayicon_mac.mm
+@@ -536,7 +536,7 @@ private:
+ #ifndef QT_MAC_USE_COCOA
+                 const short scale = GetMBarHeight();
+ #else
+-                const short scale = [[NSApp mainMenu] menuBarHeight];
++                const short scale = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ #endif
+                 NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
+                 [item setImage: nsimage];
+--- src/gui/widgets/qcocoamenu_mac.mm.orig
++++ src/gui/widgets/qcocoamenu_mac.mm
+@@ -202,7 +202,7 @@ QT_USE_NAMESPACE
+      static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
+      if (index == -1 && selForOFCP == actionSelector) {
+          // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object
+-         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
++         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
+          return [super indexOfItemWithTarget:loader andAction:actionSelector];
+      }
+      return index;
+--- src/gui/widgets/qmenu_mac.mm.orig
++++ src/gui/widgets/qmenu_mac.mm
+@@ -179,7 +179,7 @@ static void cancelAllMenuTracking()
+ {
+ #ifdef QT_MAC_USE_COCOA
+     QMacCocoaAutoReleasePool pool;
+-    NSMenu *mainMenu = [NSApp mainMenu];
++    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
+     [mainMenu cancelTracking];
+     for (NSMenuItem *item in [mainMenu itemArray]) {
+         if ([item submenu]) {
+@@ -633,7 +633,7 @@ static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarP
+ 
+ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader()
+ {
+-    return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
++    return [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
+ }
+ 
+ static NSMenuItem *createNSMenuItem(const QString &title)
+@@ -2033,7 +2033,7 @@ void qt_mac_clear_menubar()
+     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+     NSMenu *menu = [loader menu];
+     [loader ensureAppMenuInMenu:menu];
+-    [NSApp setMainMenu:menu];
++    [[NSApplication sharedApplication] setMainMenu:menu];
+     const bool modal = qt_mac_should_disable_menu(0);
+     if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
+         qt_mac_set_modal_state(menu, modal);
+@@ -2100,7 +2100,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
+ #else
+             QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+             [loader ensureAppMenuInMenu:menu];
+-            [NSApp setMainMenu:menu];
++            [[NSApplication sharedApplication] setMainMenu:menu];
+             syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
+ 
+             if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
+@@ -2140,7 +2140,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
+ #else
+                 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+                 [loader ensureAppMenuInMenu:menu];
+-                [NSApp setMainMenu:menu];
++                [[NSApplication sharedApplication] setMainMenu:menu];
+                 syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar);
+ #endif
+                 qt_mac_set_modal_state(menu, modal);
+--- src/corelib/global/qglobal.cpp.orig
++++ src/corelib/global/qglobal.cpp
+@@ -1185,6 +1185,7 @@ bool qSharedBuild()
+     \value MV_10_7     OS X 10.7
+     \value MV_10_8     OS X 10.8
+     \value MV_10_9     OS X 10.9
++    \value MV_10_10    OS X 10.10
+     \value MV_Unknown  An unknown and currently unsupported platform
+ 
+     \value MV_CHEETAH  Apple codename for MV_10_0
+@@ -1197,6 +1198,7 @@ bool qSharedBuild()
+     \value MV_LION     Apple codename for MV_10_7
+     \value MV_MOUNTAINLION Apple codename for MV_10_8
+     \value MV_MAVERICKS    Apple codename for MV_10_9
++    \value MV_YOSEMITE     Apple codename for MV_10_10
+ 
+     \sa WinVersion, SymbianVersion
+ */
+@@ -1674,8 +1676,9 @@ static QSysInfo::MacVersion macVersion()
+ {
+ #if !defined(Q_OS_IOS)
+     SInt32 gestalt_version;
+-    if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
+-        return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
++    if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) {
++        // add 2 because OS X 10.0 is 0x02 in the enum
++        return QSysInfo::MacVersion(gestalt_version + 2);
+     }
+ #endif
+     return QSysInfo::MV_Unknown;
+--- src/corelib/global/qglobal.h.orig
++++ src/corelib/global/qglobal.h
+@@ -304,31 +304,69 @@ namespace QT_NAMESPACE {}
+ #endif
+ 
+ #ifdef Q_OS_DARWIN
+-#  ifdef MAC_OS_X_VERSION_MIN_REQUIRED
+-#    undef MAC_OS_X_VERSION_MIN_REQUIRED
+-#  endif
+-#  define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
+ #  include <AvailabilityMacros.h>
+-#  if !defined(MAC_OS_X_VERSION_10_3)
+-#     define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1
++#
++#  // Availability.h was introduced with the OS X 10.6 SDK
++#  if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060) || \
++      (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)
++#    include <Availability.h>
++#  endif
++#
++#  ifdef Q_OS_MACX
++#    if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < 1040
++#       undef __MAC_OS_X_VERSION_MIN_REQUIRED
++#       define __MAC_OS_X_VERSION_MIN_REQUIRED 1040
++#    endif
++#    if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < 1040
++#       undef MAC_OS_X_VERSION_MIN_REQUIRED
++#       define MAC_OS_X_VERSION_MIN_REQUIRED 1040
++#    endif
++#  endif
++#
++#  // Numerical checks are preferred to named checks, but to be safe
++#  // we define the missing version names in case Qt uses them.
++#
++#  if !defined(__MAC_10_4)
++#       define __MAC_10_4 1040
++#  endif
++#  if !defined(__MAC_10_5)
++#       define __MAC_10_5 1050
++#  endif
++#  if !defined(__MAC_10_6)
++#       define __MAC_10_6 1060
++#  endif
++#  if !defined(__MAC_10_7)
++#       define __MAC_10_7 1070
++#  endif
++#  if !defined(__MAC_10_8)
++#       define __MAC_10_8 1080
++#  endif
++#  if !defined(__MAC_10_9)
++#       define __MAC_10_9 1090
++#  endif
++#  if !defined(__MAC_10_10)
++#       define __MAC_10_10 101000
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_4)
+-#       define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1
++#       define MAC_OS_X_VERSION_10_4 1040
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_5)
+-#       define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1
++#       define MAC_OS_X_VERSION_10_5 1050
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_6)
+-#       define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
++#       define MAC_OS_X_VERSION_10_6 1060
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_7)
+-#       define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1
++#       define MAC_OS_X_VERSION_10_7 1070
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_8)
+-#       define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1
++#       define MAC_OS_X_VERSION_10_8 1080
+ #  endif
+ #  if !defined(MAC_OS_X_VERSION_10_9)
+-#       define MAC_OS_X_VERSION_10_9 MAC_OS_X_VERSION_10_8 + 1
++#       define MAC_OS_X_VERSION_10_9 1090
++#  endif
++#  if !defined(MAC_OS_X_VERSION_10_10)
++#       define MAC_OS_X_VERSION_10_10 101000
+ #  endif
+ #endif
+ 
+@@ -1630,6 +1668,7 @@ public:
+         MV_10_7 = 0x0009,
+         MV_10_8 = 0x000A,
+         MV_10_9 = 0x000B,
++        MV_10_10 = 0x000C,
+ 
+         /* codenames */
+         MV_CHEETAH = MV_10_0,
+@@ -1641,7 +1680,8 @@ public:
+         MV_SNOWLEOPARD = MV_10_6,
+         MV_LION = MV_10_7,
+         MV_MOUNTAINLION = MV_10_8,
+-        MV_MAVERICKS = MV_10_9
++        MV_MAVERICKS = MV_10_9,
++        MV_YOSEMITE = MV_10_10
+     };
+     static const MacVersion MacintoshVersion;
+ #endif
+--- src/gui/dialogs/qcolordialog_mac.mm.orig
++++ src/gui/dialogs/qcolordialog_mac.mm
+@@ -318,7 +318,7 @@ QT_USE_NAMESPACE
+         // It's important that the modal event loop is stopped before
+         // we accept/reject QColorDialog, since QColorDialog has its
+         // own event loop that needs to be stopped last. 
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         // Since we are not in a modal event loop, we can safely close
+         // down QColorDialog
+@@ -350,7 +350,7 @@ QT_USE_NAMESPACE
+     while (!modalEnded) {
+ #ifndef QT_NO_EXCEPTIONS
+         @try {
+-            [NSApp runModalForWindow:mColorPanel];
++            [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
+             modalEnded = true;
+         } @catch (NSException *) {
+             // For some reason, NSColorPanel throws an exception when
+@@ -358,7 +358,7 @@ QT_USE_NAMESPACE
+             // palette (tab three).
+         }
+ #else
+-        [NSApp runModalForWindow:mColorPanel];
++        [[NSApplication sharedApplication] runModalForWindow:mColorPanel];
+         modalEnded = true;
+ #endif
+     }
+@@ -469,10 +469,10 @@ void QColorDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (delegate){
+         Q_Q(QColorDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/dialogs/qfiledialog_mac.mm.orig
++++ src/gui/dialogs/qfiledialog_mac.mm
+@@ -229,7 +229,7 @@ QT_USE_NAMESPACE
+     if ([mSavePanel respondsToSelector:@selector(close)])
+         [mSavePanel close];
+     if ([mSavePanel isSheet])
+-        [NSApp endSheet: mSavePanel];
++        [[NSApplication sharedApplication] endSheet: mSavePanel];
+ }
+ 
+ - (void)showModelessPanel
+@@ -1162,10 +1162,10 @@ void QFileDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (nativeDialogInUse){
+         Q_Q(QFileDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/dialogs/qfontdialog_mac.mm.orig
++++ src/gui/dialogs/qfontdialog_mac.mm
+@@ -230,7 +230,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+     mAppModal = true;
+     NSWindow *ourPanel = [mStolenContentView window];
+     [ourPanel setReleasedWhenClosed:NO];
+-    [NSApp runModalForWindow:ourPanel];
++    [[NSApplication sharedApplication] runModalForWindow:ourPanel];
+     QAbstractEventDispatcher::instance()->interrupt();
+ 
+     if (mReturnCode == NSOKButton)
+@@ -256,7 +256,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+ 
+     mAppModal = false;
+     NSWindow *ourPanel = [mStolenContentView window];
+-    [NSApp beginSheet:ourPanel
++    [[NSApplication sharedApplication] beginSheet:ourPanel
+         modalForWindow:window
+         modalDelegate:0
+         didEndSelector:0
+@@ -456,7 +456,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
+ 
+     if (mAppModal) {
+         mReturnCode = code;
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         if (code == NSOKButton)
+             mPriv->fontDialog()->accept();
+@@ -636,10 +636,10 @@ void QFontDialogPrivate::mac_nativeDialogModalHelp()
+     // Do a queued meta-call to open the native modal dialog so it opens after the new
+     // event loop has started to execute (in QDialog::exec). Using a timer rather than
+     // a queued meta call is intentional to ensure that the call is only delivered when
+-    // [NSApp run] runs (timers are handeled special in cocoa). If NSApp is not
++    // [NSApplication run] runs (timers are handeled special in cocoa). If NSApplication is not
+     // running (which is the case if e.g a top-most QEventLoop has been
+     // interrupted, and the second-most event loop has not yet been reactivated (regardless
+-    // if [NSApp run] is still on the stack)), showing a native modal dialog will fail.
++    // if [NSApplication run] is still on the stack)), showing a native modal dialog will fail.
+     if (nativeDialogInUse) {
+         Q_Q(QFontDialog);
+         QTimer::singleShot(1, q, SLOT(_q_macRunNativeAppModalPanel()));
+--- src/gui/kernel/qapplication_mac.mm.orig
++++ src/gui/kernel/qapplication_mac.mm
+@@ -468,7 +468,7 @@ void qt_mac_set_app_icon(const QPixmap &pixmap)
+         image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
+     }
+ 
+-    [NSApp setApplicationIconImage:image];
++    [[NSApplication sharedApplication] setApplicationIconImage:image];
+     [image release];
+ #endif
+ }
+@@ -750,7 +750,7 @@ void qt_event_request_showsheet(QWidget *w)
+     Q_ASSERT(qt_mac_is_macsheet(w));
+ #ifdef QT_MAC_USE_COCOA
+     w->repaint();
+-    [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
++    [[NSApplication sharedApplication] beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
+         modalDelegate:nil didEndSelector:nil contextInfo:0];
+ #else
+     qt_mac_event_remove(request_showsheet_pending);
+@@ -992,7 +992,7 @@ Q_GUI_EXPORT void qt_mac_set_dock_menu(QMenu *menu)
+ {
+     qt_mac_dock_menu = menu;
+ #ifdef QT_MAC_USE_COCOA
+-    [NSApp setDockMenu:menu->macMenu()];
++    [[NSApplication sharedApplication] setDockMenu:menu->macMenu()];
+ #else
+     SetApplicationDockTileMenu(menu->macMenu());
+ #endif
+@@ -1011,7 +1011,7 @@ void qt_mac_event_release(QWidget *w)
+ #ifndef QT_MAC_USE_COCOA
+             SetApplicationDockTileMenu(0);
+ #else
+-            [NSApp setDockMenu:0];
++            [[NSApplication sharedApplication] setDockMenu:0];
+ #endif
+         }
+     }
+@@ -1463,7 +1463,7 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
+     NSWindowList(windowCount, windowList.data());
+     int firstQtWindowFound = -1;
+     for (int i = 0; i < windowCount; ++i) {
+-        NSWindow *window = [NSApp windowWithWindowNumber:windowList[i]];
++        NSWindow *window = [[NSApplication sharedApplication] windowWithWindowNumber:windowList[i]];
+         if (window) {
+             QWidget *candidateWindow = [window QT_MANGLE_NAMESPACE(qt_qwidget)];
+             if (candidateWindow && firstQtWindowFound == -1)
+@@ -3071,7 +3071,7 @@ bool QApplicationPrivate::canQuit()
+ #else
+     Q_Q(QApplication);
+ #ifdef QT_MAC_USE_COCOA
+-    [[NSApp mainMenu] cancelTracking];
++    [[[NSApplication sharedApplication] mainMenu] cancelTracking];
+ #else
+     HiliteMenu(0);
+ #endif
+@@ -3146,7 +3146,7 @@ void onApplicationChangedActivation( bool activated )
+         }
+ 
+         if (!app->activeWindow()) {
+-            OSWindowRef wp = [NSApp keyWindow];
++            OSWindowRef wp = [[NSApplication sharedApplication] keyWindow];
+             if (QWidget *tmp_w = qt_mac_find_window(wp))
+                 app->setActiveWindow(tmp_w);
+         }
+--- src/gui/kernel/qcocoaapplication_mac.mm.orig
++++ src/gui/kernel/qcocoaapplication_mac.mm
+@@ -147,7 +147,7 @@ QT_USE_NAMESPACE
+     if ([event type] == NSApplicationDefined) {
+         switch ([event subtype]) {
+             case QtCocoaEventSubTypePostMessage:
+-                [NSApp QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
++                [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_sendPostedMessage):event];
+                 return true;
+             default:
+                 break;
+@@ -174,7 +174,7 @@ QT_USE_NAMESPACE
+     // be called instead of sendEvent if redirection occurs.
+     // 'self' will then be an instance of NSApplication
+     // (and not QNSApplication)
+-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
++    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+         [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event];
+ }
+ 
+@@ -182,7 +182,7 @@ QT_USE_NAMESPACE
+ {
+     // This method will be called if
+     // no redirection occurs
+-    if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event])
++    if (![[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_filterEvent):event])
+         [super sendEvent:event];
+ }
+ 
+@@ -194,7 +194,7 @@ QT_USE_NAMESPACE
+     // visible on screen. Note: If Qt is used as a plugin, Qt will not use a 
+     // native menu bar. Hence, we will also not need to do any redirection etc. as 
+     // we do with sendEvent.
+-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
++    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+ }
+ 
+ @end
+@@ -203,7 +203,7 @@ QT_BEGIN_NAMESPACE
+ 
+ void qt_redirectNSApplicationSendEvent()
+ {
+-    if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
++    if ([[NSApplication sharedApplication] isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) {
+         // No need to change implementation since Qt
+         // already controls a subclass of NSApplication
+         return;
+--- src/gui/kernel/qcocoaapplicationdelegate_mac.mm.orig
++++ src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+@@ -122,7 +122,7 @@ static void cleanupCocoaApplicationDelegate()
+     [dockMenu release];
+     [qtMenuLoader release];
+     if (reflectionDelegate) {
+-        [NSApp setDelegate:reflectionDelegate];
++        [[NSApplication sharedApplication] setDelegate:reflectionDelegate];
+         [reflectionDelegate release];
+     }
+     [super dealloc];
+@@ -183,7 +183,7 @@ static void cleanupCocoaApplicationDelegate()
+     return [[qtMenuLoader retain] autorelease];
+ }
+ 
+-// This function will only be called when NSApp is actually running. Before
++// This function will only be called when NSApplication is actually running. Before
+ // that, the kAEQuitApplication Apple event will be sent to
+ // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
+ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+@@ -249,7 +249,7 @@ static void cleanupCocoaApplicationDelegate()
+         && [reflectionDelegate respondsToSelector:
+                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
+         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
+-    return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
++    return NO; // Someday qApp->quitOnLastWindowClosed(); when qApp and NSApplication work closer together.
+ }
+ 
+ 
+@@ -289,13 +289,26 @@ static void cleanupCocoaApplicationDelegate()
+     qt_button_down = 0;
+ }
+ 
++- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
++{
++    Q_UNUSED(theApplication);
++    Q_UNUSED(flag);
++    // The reflection delegate gets precedence
++    if (reflectionDelegate
++        && [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
++        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
++
++    onApplicationChangedActivation(true);
++    return NO;
++}
++
+ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
+ {
+     Q_UNUSED(notification);
+     QDesktopWidgetImplementation::instance()->onResize();
+ }
+ 
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate
+ {
+     [oldDelegate retain];
+     [reflectionDelegate release];
+@@ -342,12 +355,12 @@ static void cleanupCocoaApplicationDelegate()
+ {
+     Q_UNUSED(event);
+     Q_UNUSED(replyEvent);
+-    [NSApp terminate:self];
++    [[NSApplication sharedApplication] terminate:self];
+ }
+ 
+ - (void)qtDispatcherToQAction:(id)sender
+ {
+-    [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
++    [[[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+ }
+ 
+ @end
+--- src/gui/kernel/qcocoaapplicationdelegate_mac_p.h.orig
++++ src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+@@ -113,7 +113,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
+     QApplicationPrivate *qtPrivate;
+     NSMenu *dockMenu;
+     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
+-    NSObject <NSApplicationDelegate> *reflectionDelegate;
++    id <NSApplicationDelegate> reflectionDelegate;
+     bool inLaunch;
+ }
+ + (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
+@@ -122,7 +122,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
+ - (QApplicationPrivate *)qAppPrivate;
+ - (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
+ - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate;
+ - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
+ @end
+ #endif
+--- src/gui/kernel/qcocoamenuloader_mac.mm.orig
++++ src/gui/kernel/qcocoamenuloader_mac.mm
+@@ -92,8 +92,8 @@ QT_USE_NAMESPACE
+     // 'Quit' item. When changing menu bar (e.g when switching between
+     // windows with different menu bars), we never recreate this menu, but
+     // instead pull it out the current menu bar and place into the new one:
+-    NSMenu *mainMenu = [NSApp mainMenu];
+-    if ([NSApp mainMenu] == menu)
++    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
++    if ([[NSApplication sharedApplication] mainMenu] == menu)
+         return; // nothing to do (menu is the current menu bar)!
+ 
+ #ifndef QT_NAMESPACE
+@@ -201,27 +201,27 @@ QT_USE_NAMESPACE
+ 
+ - (void)terminate:(id)sender
+ {
+-    [NSApp terminate:sender];
++    [[NSApplication sharedApplication] terminate:sender];
+ }
+ 
+ - (void)orderFrontStandardAboutPanel:(id)sender
+ {
+-    [NSApp orderFrontStandardAboutPanel:sender];
++    [[NSApplication sharedApplication] orderFrontStandardAboutPanel:sender];
+ }
+ 
+ - (void)hideOtherApplications:(id)sender
+ {
+-    [NSApp hideOtherApplications:sender];
++    [[NSApplication sharedApplication] hideOtherApplications:sender];
+ }
+ 
+ - (void)unhideAllApplications:(id)sender
+ {
+-    [NSApp unhideAllApplications:sender];
++    [[NSApplication sharedApplication] unhideAllApplications:sender];
+ }
+ 
+ - (void)hide:(id)sender
+ {
+-    [NSApp hide:sender];
++    [[NSApplication sharedApplication] hide:sender];
+ }
+ 
+ - (void)qtUpdateMenubar
+@@ -258,7 +258,7 @@ QT_USE_NAMESPACE
+ 
+  - (void)orderFrontCharacterPalette:(id)sender
+  {
+-     [NSApp orderFrontCharacterPalette:sender];
++     [[NSApplication sharedApplication] orderFrontCharacterPalette:sender];
+  }
+ 
+ - (BOOL)validateMenuItem:(NSMenuItem*)menuItem
+@@ -266,7 +266,7 @@ QT_USE_NAMESPACE
+     if ([menuItem action] == @selector(hide:)
+         || [menuItem action] == @selector(hideOtherApplications:)
+         || [menuItem action] == @selector(unhideAllApplications:)) {
+-        return [NSApp validateMenuItem:menuItem];
++        return [[NSApplication sharedApplication] validateMenuItem:menuItem];
+     } else {
+         return [menuItem isEnabled];
+     }
+--- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h.orig
++++ src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+@@ -143,7 +143,7 @@ QT_END_NAMESPACE
+ {
+     // This function is called from the quit item in the menubar when this window
+     // is in the first responder chain (see also qtDispatcherToQAction above)
+-    [NSApp terminate:sender];
++    [[NSApplication sharedApplication] terminate:sender];
+ }
+ 
+ - (void)setLevel:(NSInteger)windowLevel
+@@ -364,7 +364,7 @@ QT_END_NAMESPACE
+ 
+     if ([sender draggingSource] != nil) {
+         // modifier flags might have changed, update it here since we don't send any input events.
+-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
++        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
+         modifiers = QApplication::keyboardModifiers();
+     } else {
+         // when the source is from another application the above technique will not work.
+@@ -456,7 +456,7 @@ QT_END_NAMESPACE
+ 
+     // Update modifiers:
+     if ([sender draggingSource] != nil) {
+-        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
++        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[[NSApplication sharedApplication] currentEvent] modifierFlags]);
+         modifiers = QApplication::keyboardModifiers();
+     } else {
+         modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+--- src/gui/kernel/qeventdispatcher_mac.mm.orig
++++ src/gui/kernel/qeventdispatcher_mac.mm
+@@ -461,7 +461,7 @@ static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event,
+     if (pt)
+         [pt sendEvent:event];
+     else
+-        [NSApp sendEvent:event];
++        [[NSApplication sharedApplication] sendEvent:event];
+     return true;
+ #endif
+ }
+@@ -521,12 +521,12 @@ static inline void qt_mac_waitForMoreEvents()
+     // (and free up cpu time) until at least one event occur.
+     // This implementation is a bit on the edge, but seems to
+     // work fine:
+-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
++    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+         untilDate:[NSDate distantFuture]
+         inMode:NSDefaultRunLoopMode
+         dequeue:YES];
+     if (event)
+-        [NSApp postEvent:event atStart:YES];
++        [[NSApplication sharedApplication] postEvent:event atStart:YES];
+ #endif
+ }
+ 
+@@ -537,12 +537,12 @@ static inline void qt_mac_waitForMoreModalSessionEvents()
+     // (and free up cpu time) until at least one event occur.
+     // This implementation is a bit on the edge, but seems to
+     // work fine:
+-    NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
++    NSEvent* event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+         untilDate:[NSDate distantFuture]
+         inMode:NSModalPanelRunLoopMode
+         dequeue:YES];
+     if (event)
+-        [NSApp postEvent:event atStart:YES];
++        [[NSApplication sharedApplication] postEvent:event atStart:YES];
+ }
+ #endif
+ 
+@@ -588,23 +588,23 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+         // done from the application itself. And if processEvents is called
+         // manually (rather than from a QEventLoop), we cannot enter a tight
+         // loop and block this call, but instead we need to return after one flush.
+-        // Finally, if we are to exclude user input events, we cannot call [NSApp run]
++        // Finally, if we are to exclude user input events, we cannot call [NSApplication run]
+         // as we then loose control over which events gets dispatched:
+-        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
++        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![[NSApplication sharedApplication] isRunning];
+         const bool canExec_Qt = !excludeUserEvents &&
+                 (flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec) ;
+ 
+         if (canExec_Qt && canExec_3rdParty) {
+             // We can use exec-mode, meaning that we can stay in a tight loop until
+             // interrupted. This is mostly an optimization, but it allow us to use
+-            // [NSApp run], which is the normal code path for cocoa applications.
++            // [NSApplication run], which is the normal code path for cocoa applications.
+             if (NSModalSession session = d->currentModalSession()) {
+                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
+-                while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
++                while ([[NSApplication sharedApplication] runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
+                     qt_mac_waitForMoreModalSessionEvents();
+ 
+                 if (!d->interrupt && session == d->currentModalSessionCached) {
+-                    // Someone called [NSApp stopModal:] from outside the event
++                    // Someone called [[NSApplication sharedApplication] stopModal:] from outside the event
+                     // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+                     // 'session' as well. As a result, we need to restart all internal sessions:
+                     d->temporarilyStopAllModalSessions();
+@@ -612,7 +612,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+             } else {
+                 d->nsAppRunCalledByQt = true;
+                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
+-                [NSApp run];
++                [[NSApplication sharedApplication] run];
+             }
+             retVal = true;
+         } else {
+@@ -626,9 +626,9 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                     // to use cocoa's native way of running modal sessions:
+                     if (flags & QEventLoop::WaitForMoreEvents)
+                         qt_mac_waitForMoreModalSessionEvents();
+-                    NSInteger status = [NSApp runModalSession:session];
++                    NSInteger status = [[NSApplication sharedApplication] runModalSession:session];
+                     if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+-                        // INVARIANT: Someone called [NSApp stopModal:] from outside the event
++                        // INVARIANT: Someone called [NSApplication stopModal:] from outside the event
+                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+                         // 'session' as well. As a result, we need to restart all internal sessions:
+                         d->temporarilyStopAllModalSessions();
+@@ -637,8 +637,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                 } else do {
+                     // Dispatch all non-user events (but que non-user events up for later). In
+                     // this case, we need more control over which events gets dispatched, and
+-                    // cannot use [NSApp runModalSession:session]:
+-                    event = [NSApp nextEventMatchingMask:NSAnyEventMask
++                    // cannot use [NSApplication runModalSession:session]:
++                    event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+                     untilDate:nil
+                     inMode:NSModalPanelRunLoopMode
+                     dequeue: YES];
+@@ -655,7 +655,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+                 } while (!d->interrupt && event != nil);
+             } else do {
+                 // INVARIANT: No modal window is executing.
+-                event = [NSApp nextEventMatchingMask:NSAnyEventMask
++                event = [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask
+                 untilDate:nil
+                 inMode:NSDefaultRunLoopMode
+                 dequeue: YES];
+@@ -798,12 +798,12 @@ void QEventDispatcherMacPrivate::ensureNSAppInitialized()
+     // we let Cocoa finish the initialization it seems to need. We'll only
+     // apply this trick at most once for any application, and we avoid doing it
+     // for the common case where main just starts QApplication::exec.
+-    if (nsAppRunCalledByQt || [NSApp isRunning])
++    if (nsAppRunCalledByQt || [[NSApplication sharedApplication] isRunning])
+         return;
+     nsAppRunCalledByQt = true;
+     QBoolBlocker block1(interrupt, true);
+     QBoolBlocker block2(currentExecIsNSAppRun, true);
+-    [NSApp run];
++    [[NSApplication sharedApplication] run];
+ }
+ 
+ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+@@ -812,8 +812,8 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+     // such, make them pending again. The next call to
+     // currentModalSession will recreate them again. The
+     // reason to stop all session like this is that otherwise
+-    // a call [NSApp stop] would not stop NSApp, but rather
+-    // the current modal session. So if we need to stop NSApp
++    // a call [NSApplication stop] would not stop NSApplication, but rather
++    // the current modal session. So if we need to stop NSApplication
+     // we need to stop all the modal session first. To avoid changing
+     // the stacking order of the windows while doing so, we put
+     // up a block that is used in QCocoaWindow and QCocoaPanel:
+@@ -821,7 +821,7 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
+     for (int i=0; i<stackSize; ++i) {
+         QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
+         if (info.session) {
+-            [NSApp endModalSession:info.session];
++            [[NSApplication sharedApplication] endModalSession:info.session];
+             info.session = 0;
+         }
+     }
+@@ -856,7 +856,7 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
+             info.nswindow = window;
+             [(NSWindow*) info.nswindow retain];
+             int levelBeforeEnterModal = [window level];
+-            info.session = [NSApp beginModalSessionForWindow:window];
++            info.session = [[NSApplication sharedApplication] beginModalSessionForWindow:window];
+             // Make sure we don't stack the window lower that it was before
+             // entering modal, in case it e.g. had the stays-on-top flag set:
+             if (levelBeforeEnterModal > [window level])
+@@ -926,7 +926,7 @@ void QEventDispatcherMacPrivate::cleanupModalSessions()
+         cocoaModalSessionStack.remove(i);
+         currentModalSessionCached = 0;
+         if (info.session) {
+-            [NSApp endModalSession:info.session];
++            [[NSApplication sharedApplication] endModalSession:info.session];
+             [(NSWindow *)info.nswindow release];
+         }
+     }
+@@ -1057,7 +1057,7 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
+             // pending cocoa events first).
+             if (d->currentModalSessionCached)
+                 d->temporarilyStopAllModalSessions();
+-            [NSApp stop:NSApp];
++            [[NSApplication sharedApplication] stop:[NSApplication sharedApplication]];
+             d->cancelWaitForMoreEvents();
+         }
+ #endif
+@@ -1093,7 +1093,8 @@ void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
+     // In case the event dispatcher is waiting for more
+     // events somewhere, we post a dummy event to wake it up:
+     QMacCocoaAutoReleasePool pool;
+-    [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
++    [[NSApplication sharedApplication] postEvent:[NSEvent otherEventWithType:NSApplicationDefined
++        location:NSZeroPoint
+         modifierFlags:0 timestamp:0. windowNumber:0 context:0
+         subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
+ }
+@@ -1110,7 +1111,7 @@ void QEventDispatcherMac::interrupt()
+ #else
+     // We do nothing more here than setting d->interrupt = true, and
+     // poke the event loop if it is sleeping. Actually stopping
+-    // NSApp, or the current modal session, is done inside the send
++    // NSApplication, or the current modal session, is done inside the send
+     // posted events callback. We do this to ensure that all current pending
+     // cocoa events gets delivered before we stop. Otherwise, if we now stop
+     // the last event loop recursion, cocoa will just drop pending posted
+@@ -1165,7 +1166,7 @@ QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false)
+     // The whole point of this class is that we enable a way to interrupt
+     // the event dispatcher when returning back to a lower recursion level
+     // than where interruptLater was called. This is needed to detect if
+-    // [NSApp run] should still be running at the recursion level it is at.
++    // [NSApplication run] should still be running at the recursion level it is at.
+     // Since the interrupt is canceled if processEvents is called before
+     // this object gets deleted, we also avoid interrupting unnecessary.
+     deleteLater();
+--- src/gui/kernel/qt_cocoa_helpers_mac.mm.orig
++++ src/gui/kernel/qt_cocoa_helpers_mac.mm
+@@ -1697,7 +1697,7 @@ void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2
+     NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
+         location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
+         context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
+-    [NSApp postEvent:e atStart:NO];
++    [[NSApplication sharedApplication] postEvent:e atStart:NO];
+ }
+ 
+ void qt_cocoaPostMessageAfterEventLoopExit(id target, SEL selector, int argCount, id arg1, id arg2)
+@@ -1727,7 +1727,7 @@ void qt_mac_post_retranslateAppMenu()
+ {
+ #ifdef QT_MAC_USE_COCOA
+     QMacCocoaAutoReleasePool pool;
+-    qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
++    qt_cocoaPostMessage([[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
+ #endif
+ }
+ 
+--- src/gui/kernel/qt_mac_p.h.orig
++++ src/gui/kernel/qt_mac_p.h
+@@ -75,6 +75,62 @@
+ 
+ #include <Carbon/Carbon.h>
+ 
++#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
++    // Some deprecated functions have been removed from the the 10.7 SDK, but the symbols are
++    // still exported by the 32-bit QD.framework (a subframework of ApplicationServices).
++    extern "C" {
++        // from QuickdrawAPI.h
++        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/QuickDraw_Ref/QuickDraw_Ref.pdf
++        void          CopyBits(const BitMap *srcBits, const BitMap *dstBits, const Rect *srcRect, const Rect *dstRect, short mode, RgnHandle maskRgn);
++        void          CopyRgn(RgnHandle srcRgn, RgnHandle dstRgn);
++        void          DisposeRgn(RgnHandle rgn);
++        GDHandle      GetMainDevice(void);
++        const BitMap *GetPortBitMapForCopyBits(CGrafPtr port);
++        Rect         *GetRegionBounds(RgnHandle region, Rect *bounds);
++        RgnHandle     NewRgn(void);
++        OSStatus      QDRegionToRects(RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void *userData);
++        void          SetEmptyRgn(RgnHandle rgn);
++        void          SetRect(Rect* r, short left, short top, short right, short bottom);
++        void          SetRectRgn(RgnHandle rgn, short left, short top, short right, short bottom);
++        void          UnionRgn(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn);
++        enum {
++            kQDRegionToRectsMsgInit       = 1,
++            kQDRegionToRectsMsgParse      = 2,
++            kQDRegionToRectsMsgTerminate  = 3
++        };
++        enum {
++            kQDParseRegionFromTop         = (1 << 0),
++            kQDParseRegionFromBottom      = (1 << 1),
++            kQDParseRegionFromLeft        = (1 << 2),
++            kQDParseRegionFromRight       = (1 << 3),
++            kQDParseRegionFromTopLeft     = kQDParseRegionFromTop | kQDParseRegionFromLeft,
++            kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight
++        };
++
++        // from Fonts.h
++        // https://developer.apple.com/legacy/library/documentation/Carbon/reference/Font_Manager/fm_reference.pdf
++        OSStatus         FMCreateFontIterator(const FMFilter *iFilter, void *iRefCon, OptionBits iOptions, FMFontIterator *ioIterator);
++        OSStatus         FMDisposeFontIterator(FMFontIterator *ioIterator);
++        ATSFontFamilyRef FMGetATSFontFamilyRefFromFont(FMFontFamily iFamily);
++        ATSFontFamilyRef FMGetATSFontFamilyRefFromFontFamily(FMFontFamily iFamily);
++        ATSFontRef       FMGetATSFontRefFromFont(FMFont iFont);
++        OSStatus         FMGetFontFamilyInstanceFromFont(FMFont iFont, FMFontFamily *oFontFamily, FMFontStyle *oStyle);
++        FMFontFamily     FMGetFontFamilyFromATSFontFamilyRef(ATSFontFamilyRef iFamily);
++        FMFont           FMGetFontFromATSFontRef(ATSFontRef iFont);
++        OSStatus         FMGetFontFromFontFamilyInstance(FMFontFamily iFontFamily, FMFontStyle iStyle, FMFont *oFont, FMFontStyle *oIntrinsicStyle);
++        OSStatus         FMGetNextFont(FMFontIterator *ioIterator, FMFont *oFont);
++        enum {
++            kFMUseGlobalScopeOption       = 0x00000001
++        };
++        enum {
++            commandMark                   = 17,
++            checkMark                     = 18,
++            diamondMark                   = 19,
++            appleMark                     = 20
++        };
++    }
++#endif
++
+ QT_BEGIN_NAMESPACE
+ class QWidget;
+ class QDragMoveEvent;
+--- src/gui/kernel/qwidget_mac.mm.orig
++++ src/gui/kernel/qwidget_mac.mm
+@@ -220,7 +220,7 @@ static QSize qt_mac_desktopSize()
+ static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
+ {
+     NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->effectiveWinId());
+-    NSArray *windows = [NSApp windows];
++    NSArray *windows = [[NSApplication sharedApplication] windows];
+     for (NSWindow *window in windows) {
+         NSArray *drawers = [window drawers];
+         for (NSDrawer *drawer in drawers) {
+@@ -254,7 +254,7 @@ static void qt_mac_destructWindow(OSWindowRef window)
+ {
+ #ifdef QT_MAC_USE_COCOA
+     if ([window isVisible] && [window isSheet]){
+-        [NSApp endSheet:window];
++        [[NSApplication sharedApplication] endSheet:window];
+         [window orderOut:window];
+     }
+ 
+@@ -2439,7 +2439,7 @@ void QWidgetPrivate::recreateMacWindow()
+     }
+     if ([oldWindow isVisible]){
+         if ([oldWindow isSheet])
+-            [NSApp endSheet:oldWindow];
++            [[NSApplication sharedApplication] endSheet:oldWindow];
+         [oldWindow orderOut:oldWindow];
+         show_sys();
+     }
+@@ -3554,7 +3554,7 @@ void QWidgetPrivate::show_sys()
+     }
+ 
+ #ifdef QT_MAC_USE_COCOA
+-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+         // Update enter/leave immidiatly, don't wait for a move event. But only
+         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+         QPoint qlocal, qglobal;
+@@ -3605,7 +3605,7 @@ void QWidgetPrivate::hide_sys()
+             else
+                 HideSheetWindow(window);
+ #else
+-            [NSApp endSheet:window];
++            [[NSApplication sharedApplication] endSheet:window];
+             [window orderOut:window];
+ #endif
+         } else if(qt_mac_is_macdrawer(q)) {
+@@ -3716,7 +3716,7 @@ void QWidgetPrivate::hide_sys()
+     }
+ 
+ #ifdef QT_MAC_USE_COCOA
+-    if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] && !qt_button_down && !QWidget::mouseGrabber()){
+         // Update enter/leave immidiatly, don't wait for a move event. But only
+         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
+         QPoint qlocal, qglobal;
+--- src/gui/styles/qmacstyle_mac.mm.orig
++++ src/gui/styles/qmacstyle_mac.mm
+@@ -780,7 +780,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
+             if (!GetThemeMenuBarHeight(&size))
+                 ret = QSize(-1, size);
+ #else
+-            ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
++            ret = QSize(-1, [[[NSApplication sharedApplication] mainMenu] menuBarHeight]);
+             // In the qt_mac_set_native_menubar(false) case,
+             // we come it here with a zero-height main menu,
+             // preventing the in-window menu from displaying.
+@@ -3024,16 +3024,14 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
+                 fdi.version = qt_mac_hitheme_version;
+                 fdi.state = tds;
+                 SInt32 frame_size;
+-                if (pe == PE_FrameLineEdit) {
+-                    fdi.kind = kHIThemeFrameTextFieldSquare;
+-                    GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
+-                    if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
+-                        fdi.state = kThemeStateInactive;
+-                } else {
+-                    baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
+-                    fdi.kind = kHIThemeFrameListBox;
+-                    GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size);
+-                }
++                fdi.kind = kHIThemeFrameTextFieldSquare;
++                GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size);
++                if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled))
++                    fdi.state = kThemeStateInactive;
++                else if (fdi.state == kThemeStatePressed)
++                    // This pressed state doesn't make sense for a line edit frame.
++                    // And Yosemite agrees with us. Otherwise it starts showing yellow pixels.
++                    fdi.state = kThemeStateActive;
+                 fdi.isFocused = (frame->state & State_HasFocus);
+                 int lw = frame->lineWidth;
+                 if (lw <= 0)
+--- src/gui/util/qsystemtrayicon_mac.mm.orig
++++ src/gui/util/qsystemtrayicon_mac.mm
+@@ -536,7 +536,7 @@ private:
+ #ifndef QT_MAC_USE_COCOA
+                 const short scale = GetMBarHeight();
+ #else
+-                const short scale = [[NSApp mainMenu] menuBarHeight];
++                const short scale = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ #endif
+                 NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
+                 [item setImage: nsimage];
+--- src/gui/widgets/qcocoamenu_mac.mm.orig
++++ src/gui/widgets/qcocoamenu_mac.mm
+@@ -202,7 +202,7 @@ QT_USE_NAMESPACE
+      static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
+      if (index == -1 && selForOFCP == actionSelector) {
+          // Check if the 'orderFrontCharacterPalette' SEL exists for QCocoaMenuLoader object
+-         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
++         QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
+          return [super indexOfItemWithTarget:loader andAction:actionSelector];
+      }
+      return index;
+--- src/gui/widgets/qmenu_mac.mm.orig
++++ src/gui/widgets/qmenu_mac.mm
+@@ -179,7 +179,7 @@ static void cancelAllMenuTracking()
+ {
+ #ifdef QT_MAC_USE_COCOA
+     QMacCocoaAutoReleasePool pool;
+-    NSMenu *mainMenu = [NSApp mainMenu];
++    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
+     [mainMenu cancelTracking];
+     for (NSMenuItem *item in [mainMenu itemArray]) {
+         if ([item submenu]) {
+@@ -633,7 +633,7 @@ static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarP
+ 
+ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader()
+ {
+-    return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
++    return [[NSApplication sharedApplication] QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
+ }
+ 
+ static NSMenuItem *createNSMenuItem(const QString &title)
+@@ -2033,7 +2033,7 @@ void qt_mac_clear_menubar()
+     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+     NSMenu *menu = [loader menu];
+     [loader ensureAppMenuInMenu:menu];
+-    [NSApp setMainMenu:menu];
++    [[NSApplication sharedApplication] setMainMenu:menu];
+     const bool modal = qt_mac_should_disable_menu(0);
+     if (qt_mac_current_menubar.qmenubar || modal != qt_mac_current_menubar.modal)
+         qt_mac_set_modal_state(menu, modal);
+@@ -2100,7 +2100,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
+ #else
+             QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+             [loader ensureAppMenuInMenu:menu];
+-            [NSApp setMainMenu:menu];
++            [[NSApplication sharedApplication] setMainMenu:menu];
+             syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
+ 
+             if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
+@@ -2140,7 +2140,7 @@ bool QMenuBarPrivate::macUpdateMenuBarImmediatly()
+ #else
+                 QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+                 [loader ensureAppMenuInMenu:menu];
+-                [NSApp setMainMenu:menu];
++                [[NSApplication sharedApplication] setMainMenu:menu];
+                 syncMenuBarItemsVisiblity(qt_mac_current_menubar.qmenubar->d_func()->mac_menubar);
+ #endif
+                 qt_mac_set_modal_state(menu, modal);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20141016/881bc11e/attachment-0001.html>


More information about the macports-changes mailing list