<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[126865] trunk/dports/aqua/qt4-mac</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/126865">126865</a></dd>
<dt>Author</dt> <dd>michaelld@macports.org</dd>
<dt>Date</dt> <dd>2014-10-16 11:19:17 -0700 (Thu, 16 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>qt4-mac: minimal update for Yosimite (10.10); no rev-bump necessary.  Addresses ticket #44017.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportsaquaqt4macPortfile">trunk/dports/aqua/qt4-mac/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdportsaquaqt4macfilespatch1010diff">trunk/dports/aqua/qt4-mac/files/patch-10.10.diff</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportsaquaqt4macPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/aqua/qt4-mac/Portfile (126864 => 126865)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -240,15 +240,20 @@
</span><span class="cx"> patchfiles-append   \
</span><span class="cx">     patch-tools_macdeployqt_shared_shared.cpp.diff
</span><span class="cx"> 
</span><del>-# error out if trying to build on a new OSX version (&gt; 10.9).
</del><ins>+# (24) minimum patches required for 10.10; squashed; temporary until 4.8.7.
</ins><span class="cx"> 
</span><ins>+patchfiles-append   \
+    patch-10.10.diff
+
+# error out if trying to build on a new OSX version (&gt; 10.10).
+
</ins><span class="cx"> platform darwin {
</span><del>-    if {${MINOR} &gt; 9} {
</del><ins>+    if {${MINOR} &gt; 10} {
</ins><span class="cx">         # This project needs to be updated to build with clang++ against libc++
</span><span class="cx">         depends_lib
</span><span class="cx">         depends_run
</span><span class="cx">         pre-fetch {
</span><del>-            ui_error &quot;$name does not currently build on OSX later than 10.9 'Mavericks'.&quot;
</del><ins>+            ui_error &quot;$name does not currently build on OSX later than 10.10 'Yosemite'.&quot;
</ins><span class="cx">             error &quot;unsupported platform&quot;
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkdportsaquaqt4macfilespatch1010diff"></a>
<div class="addfile"><h4>Added: trunk/dports/aqua/qt4-mac/files/patch-10.10.diff (0 => 126865)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,1968 @@
</span><ins>+--- 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, &amp;gestalt_version) == noErr) {
+-        return QSysInfo::MacVersion(((gestalt_version &amp; 0x00F0) &gt;&gt; 4) + 2);
++    if (Gestalt(gestaltSystemVersionMinor, &amp;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 &lt;AvailabilityMacros.h&gt;
+-#  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) &amp;&amp; __MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 1060) || \
++      (defined(MAC_OS_X_VERSION_MAX_ALLOWED) &amp;&amp; MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 1060)
++#    include &lt;Availability.h&gt;
++#  endif
++#
++#  ifdef Q_OS_MACX
++#    if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 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 &lt; 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 &amp;resolveFont)
+     mAppModal = true;
+     NSWindow *ourPanel = [mStolenContentView window];
+     [ourPanel setReleasedWhenClosed:NO];
+-    [NSApp runModalForWindow:ourPanel];
++    [[NSApplication sharedApplication] runModalForWindow:ourPanel];
+     QAbstractEventDispatcher::instance()-&gt;interrupt();

+     if (mReturnCode == NSOKButton)
+@@ -256,7 +256,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &amp;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 &amp;resolveFont)

+     if (mAppModal) {
+         mReturnCode = code;
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         if (code == NSOKButton)
+             mPriv-&gt;fontDialog()-&gt;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 &amp;pixmap)
+         image = static_cast&lt;NSImage *&gt;(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-&gt;repaint();
+-    [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w-&gt;parentWidget())
++    [[NSApplication sharedApplication] beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w-&gt;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-&gt;macMenu()];
++    [[NSApplication sharedApplication] setDockMenu:menu-&gt;macMenu()];
+ #else
+     SetApplicationDockTileMenu(menu-&gt;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 &amp;p)
+     NSWindowList(windowCount, windowList.data());
+     int firstQtWindowFound = -1;
+     for (int i = 0; i &lt; 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 &amp;&amp; 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-&gt;activeWindow()) {
+-            OSWindowRef wp = [NSApp keyWindow];
++            OSWindowRef wp = [[NSApplication sharedApplication] keyWindow];
+             if (QWidget *tmp_w = qt_mac_find_window(wp))
+                 app-&gt;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()
+         &amp;&amp; [reflectionDelegate respondsToSelector:
+                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
+         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
+-    return NO; // Someday qApp-&gt;quitOnLastWindowClosed(); when QApp and NSApp work closer together.
++    return NO; // Someday qApp-&gt;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
++        &amp;&amp; [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
++        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
++
++    onApplicationChangedActivation(true);
++    return NO;
++}
++
+ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
+ {
+     Q_UNUSED(notification);
+     QDesktopWidgetImplementation::instance()-&gt;onResize();
+ }

+-- (void)setReflectionDelegate:(NSObject &lt;NSApplicationDelegate&gt; *)oldDelegate
++- (void)setReflectionDelegate:(id &lt;NSApplicationDelegate&gt;)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 &lt;NSApplicationDelegate&gt; *reflectionDelegate;
++    id &lt;NSApplicationDelegate&gt; 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 &lt;NSApplicationDelegate&gt; *)oldDelegate;
++- (void)setReflectionDelegate:(id &lt;NSApplicationDelegate&gt;)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-&gt;nsAppRunCalledByQt || ![NSApp isRunning];
++        const bool canExec_3rdParty = d-&gt;nsAppRunCalledByQt || ![[NSApplication sharedApplication] isRunning];
+         const bool canExec_Qt = !excludeUserEvents &amp;&amp;
+                 (flags &amp; QEventLoop::DialogExec || flags &amp; QEventLoop::EventLoopExec) ;

+         if (canExec_Qt &amp;&amp; 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-&gt;currentModalSession()) {
+                 QBoolBlocker execGuard(d-&gt;currentExecIsNSAppRun, false);
+-                while ([NSApp runModalSession:session] == NSRunContinuesResponse &amp;&amp; !d-&gt;interrupt)
++                while ([[NSApplication sharedApplication] runModalSession:session] == NSRunContinuesResponse &amp;&amp; !d-&gt;interrupt)
+                     qt_mac_waitForMoreModalSessionEvents();

+                 if (!d-&gt;interrupt &amp;&amp; session == d-&gt;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-&gt;temporarilyStopAllModalSessions();
+@@ -612,7 +612,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+             } else {
+                 d-&gt;nsAppRunCalledByQt = true;
+                 QBoolBlocker execGuard(d-&gt;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 &amp; QEventLoop::WaitForMoreEvents)
+                         qt_mac_waitForMoreModalSessionEvents();
+-                    NSInteger status = [NSApp runModalSession:session];
++                    NSInteger status = [[NSApplication sharedApplication] runModalSession:session];
+                     if (status != NSRunContinuesResponse &amp;&amp; session == d-&gt;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-&gt;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-&gt;interrupt &amp;&amp; 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&lt;stackSize; ++i) {
+         QCocoaModalSessionInfo &amp;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 &gt; [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-&gt;currentModalSessionCached)
+                 d-&gt;temporarilyStopAllModalSessions();
+-            [NSApp stop:NSApp];
++            [[NSApplication sharedApplication] stop:[NSApplication sharedApplication]];
+             d-&gt;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-&gt;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 &lt;Carbon/Carbon.h&gt;

++#if !defined(QT_MAC_USE_COCOA) &amp;&amp; defined(MAC_OS_X_VERSION_10_7) &amp;&amp; MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 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 &quot;C&quot; {
++        // 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 &lt;&lt; 0),
++            kQDParseRegionFromBottom      = (1 &lt;&lt; 1),
++            kQDParseRegionFromLeft        = (1 &lt;&lt; 2),
++            kQDParseRegionFromRight       = (1 &lt;&lt; 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&lt;NSView *&gt;(widget-&gt;window()-&gt;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] &amp;&amp; [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] &amp;&amp; !qt_button_down &amp;&amp; !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] &amp;&amp; !qt_button_down &amp;&amp; !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] &amp;&amp; !qt_button_down &amp;&amp; !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] &amp;&amp; !qt_button_down &amp;&amp; !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(&amp;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, &amp;frame_size);
+-                    if ((frame-&gt;state &amp; State_ReadOnly) || !(frame-&gt;state &amp; State_Enabled))
+-                        fdi.state = kThemeStateInactive;
+-                } else {
+-                    baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
+-                    fdi.kind = kHIThemeFrameListBox;
+-                    GetThemeMetric(kThemeMetricListBoxFrameOutset, &amp;frame_size);
+-                }
++                fdi.kind = kHIThemeFrameTextFieldSquare;
++                GetThemeMetric(kThemeMetricEditTextFrameOutset, &amp;frame_size);
++                if ((frame-&gt;state &amp; State_ReadOnly) || !(frame-&gt;state &amp; 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-&gt;state &amp; State_HasFocus);
+                 int lw = frame-&gt;lineWidth;
+                 if (lw &lt;= 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&lt;NSImage *&gt;(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(@&quot;orderFrontCharacterPalette:&quot;);
+      if (index == -1 &amp;&amp; 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 &amp;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-&gt;d_func()-&gt;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-&gt;d_func()-&gt;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, &amp;gestalt_version) == noErr) {
+-        return QSysInfo::MacVersion(((gestalt_version &amp; 0x00F0) &gt;&gt; 4) + 2);
++    if (Gestalt(gestaltSystemVersionMinor, &amp;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 &lt;AvailabilityMacros.h&gt;
+-#  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) &amp;&amp; __MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 1060) || \
++      (defined(MAC_OS_X_VERSION_MAX_ALLOWED) &amp;&amp; MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 1060)
++#    include &lt;Availability.h&gt;
++#  endif
++#
++#  ifdef Q_OS_MACX
++#    if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 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 &lt; 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 &amp;resolveFont)
+     mAppModal = true;
+     NSWindow *ourPanel = [mStolenContentView window];
+     [ourPanel setReleasedWhenClosed:NO];
+-    [NSApp runModalForWindow:ourPanel];
++    [[NSApplication sharedApplication] runModalForWindow:ourPanel];
+     QAbstractEventDispatcher::instance()-&gt;interrupt();

+     if (mReturnCode == NSOKButton)
+@@ -256,7 +256,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &amp;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 &amp;resolveFont)

+     if (mAppModal) {
+         mReturnCode = code;
+-        [NSApp stopModalWithCode:code];
++        [[NSApplication sharedApplication] stopModalWithCode:code];
+     } else {
+         if (code == NSOKButton)
+             mPriv-&gt;fontDialog()-&gt;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 &amp;pixmap)
+         image = static_cast&lt;NSImage *&gt;(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-&gt;repaint();
+-    [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w-&gt;parentWidget())
++    [[NSApplication sharedApplication] beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w-&gt;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-&gt;macMenu()];
++    [[NSApplication sharedApplication] setDockMenu:menu-&gt;macMenu()];
+ #else
+     SetApplicationDockTileMenu(menu-&gt;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 &amp;p)
+     NSWindowList(windowCount, windowList.data());
+     int firstQtWindowFound = -1;
+     for (int i = 0; i &lt; 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 &amp;&amp; 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-&gt;activeWindow()) {
+-            OSWindowRef wp = [NSApp keyWindow];
++            OSWindowRef wp = [[NSApplication sharedApplication] keyWindow];
+             if (QWidget *tmp_w = qt_mac_find_window(wp))
+                 app-&gt;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()
+         &amp;&amp; [reflectionDelegate respondsToSelector:
+                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
+         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
+-    return NO; // Someday qApp-&gt;quitOnLastWindowClosed(); when QApp and NSApp work closer together.
++    return NO; // Someday qApp-&gt;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
++        &amp;&amp; [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
++        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
++
++    onApplicationChangedActivation(true);
++    return NO;
++}
++
+ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
+ {
+     Q_UNUSED(notification);
+     QDesktopWidgetImplementation::instance()-&gt;onResize();
+ }

+-- (void)setReflectionDelegate:(NSObject &lt;NSApplicationDelegate&gt; *)oldDelegate
++- (void)setReflectionDelegate:(id &lt;NSApplicationDelegate&gt;)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 &lt;NSApplicationDelegate&gt; *reflectionDelegate;
++    id &lt;NSApplicationDelegate&gt; 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 &lt;NSApplicationDelegate&gt; *)oldDelegate;
++- (void)setReflectionDelegate:(id &lt;NSApplicationDelegate&gt;)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-&gt;nsAppRunCalledByQt || ![NSApp isRunning];
++        const bool canExec_3rdParty = d-&gt;nsAppRunCalledByQt || ![[NSApplication sharedApplication] isRunning];
+         const bool canExec_Qt = !excludeUserEvents &amp;&amp;
+                 (flags &amp; QEventLoop::DialogExec || flags &amp; QEventLoop::EventLoopExec) ;

+         if (canExec_Qt &amp;&amp; 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-&gt;currentModalSession()) {
+                 QBoolBlocker execGuard(d-&gt;currentExecIsNSAppRun, false);
+-                while ([NSApp runModalSession:session] == NSRunContinuesResponse &amp;&amp; !d-&gt;interrupt)
++                while ([[NSApplication sharedApplication] runModalSession:session] == NSRunContinuesResponse &amp;&amp; !d-&gt;interrupt)
+                     qt_mac_waitForMoreModalSessionEvents();

+                 if (!d-&gt;interrupt &amp;&amp; session == d-&gt;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-&gt;temporarilyStopAllModalSessions();
+@@ -612,7 +612,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
+             } else {
+                 d-&gt;nsAppRunCalledByQt = true;
+                 QBoolBlocker execGuard(d-&gt;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 &amp; QEventLoop::WaitForMoreEvents)
+                         qt_mac_waitForMoreModalSessionEvents();
+-                    NSInteger status = [NSApp runModalSession:session];
++                    NSInteger status = [[NSApplication sharedApplication] runModalSession:session];
+                     if (status != NSRunContinuesResponse &amp;&amp; session == d-&gt;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-&gt;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-&gt;interrupt &amp;&amp; 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&lt;stackSize; ++i) {
+         QCocoaModalSessionInfo &amp;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 &gt; [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-&gt;currentModalSessionCached)
+                 d-&gt;temporarilyStopAllModalSessions();
+-            [NSApp stop:NSApp];
++            [[NSApplication sharedApplication] stop:[NSApplication sharedApplication]];
+             d-&gt;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-&gt;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 &lt;Carbon/Carbon.h&gt;

++#if !defined(QT_MAC_USE_COCOA) &amp;&amp; defined(MAC_OS_X_VERSION_10_7) &amp;&amp; MAC_OS_X_VERSION_MAX_ALLOWED &gt;= 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 &quot;C&quot; {
++        // 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 &lt;&lt; 0),
++            kQDParseRegionFromBottom      = (1 &lt;&lt; 1),
++            kQDParseRegionFromLeft        = (1 &lt;&lt; 2),
++            kQDParseRegionFromRight       = (1 &lt;&lt; 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&lt;NSView *&gt;(widget-&gt;window()-&gt;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] &amp;&amp; [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] &amp;&amp; !qt_button_down &amp;&amp; !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] &amp;&amp; !qt_button_down &amp;&amp; !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] &amp;&amp; !qt_button_down &amp;&amp; !QWidget::mouseGrabber()){
++    if ([[NSApplication sharedApplication] isActive] &amp;&amp; !qt_button_down &amp;&amp; !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(&amp;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, &amp;frame_size);
+-                    if ((frame-&gt;state &amp; State_ReadOnly) || !(frame-&gt;state &amp; State_Enabled))
+-                        fdi.state = kThemeStateInactive;
+-                } else {
+-                    baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam
+-                    fdi.kind = kHIThemeFrameListBox;
+-                    GetThemeMetric(kThemeMetricListBoxFrameOutset, &amp;frame_size);
+-                }
++                fdi.kind = kHIThemeFrameTextFieldSquare;
++                GetThemeMetric(kThemeMetricEditTextFrameOutset, &amp;frame_size);
++                if ((frame-&gt;state &amp; State_ReadOnly) || !(frame-&gt;state &amp; 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-&gt;state &amp; State_HasFocus);
+                 int lw = frame-&gt;lineWidth;
+                 if (lw &lt;= 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&lt;NSImage *&gt;(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(@&quot;orderFrontCharacterPalette:&quot;);
+      if (index == -1 &amp;&amp; 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 &amp;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-&gt;d_func()-&gt;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-&gt;d_func()-&gt;mac_menubar);
+ #endif
+                 qt_mac_set_modal_state(menu, modal);
</ins></span></pre>
</div>
</div>

</body>
</html>