              if (QWidget *tmp_w = qt_mac_find_window(wp))
                  app->setActiveWindow(tmp_w);
          }
+diff -ruN qt-4.8.6/src/gui/kernel/qcocoaapplicationdelegate_mac.mm qt-4.8.6-new/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+--- qt-4.8.6/src/gui/kernel/qcocoaapplicationdelegate_mac.mm	2014-04-10 12:37:12.000000000 -0600
++++ qt-4.8.6-new/src/gui/kernel/qcocoaapplicationdelegate_mac.mm	2015-03-08 04:49:48.932928428 -0600
+@@ -122,7 +122,7 @@
+     [dockMenu release];
+     [qtMenuLoader release];
+     if (reflectionDelegate) {
+-        [NSApp setDelegate:reflectionDelegate];
++        [[NSApplication sharedApplication] setDelegate:reflectionDelegate];
+         [reflectionDelegate release];
+     }
+     [super dealloc];
+@@ -183,7 +183,7 @@
+     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 @@
+         && [reflectionDelegate respondsToSelector:
+                             @selector(applicationShouldTerminateAfterLastWindowClosed:)])
+         return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender];
+-    return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
++    return NO; // Someday qApp->quitOnLastWindowClosed(); when qApp and NSApplication work closer together.
+ }
+ 
+ 
+@@ -289,13 +289,26 @@
+     qt_button_down = 0;
+ }
+ 
++- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
++{
++    Q_UNUSED(theApplication);
++    Q_UNUSED(flag);
++    // The reflection delegate gets precedence
++    if (reflectionDelegate
++        && [reflectionDelegate respondsToSelector:@selector(applicationShouldHandleReopen:hasVisibleWindows:)])
++        return [reflectionDelegate applicationShouldHandleReopen:theApplication hasVisibleWindows:flag];
++
++    onApplicationChangedActivation(true);
++    return NO;
++}
++
+ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
+ {
+     Q_UNUSED(notification);
+     QDesktopWidgetImplementation::instance()->onResize();
+ }
+ 
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate
+ {
+     [oldDelegate retain];
+     [reflectionDelegate release];
+@@ -342,12 +355,12 @@
+ {
+     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
+diff -ruN qt-4.8.6/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h qt-4.8.6-new/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+--- qt-4.8.6/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h	2014-04-10 12:37:12.000000000 -0600
++++ qt-4.8.6-new/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h	2015-03-08 04:49:48.932928428 -0600
+@@ -113,7 +113,7 @@
+     QApplicationPrivate *qtPrivate;
+     NSMenu *dockMenu;
+     QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
+-    NSObject <NSApplicationDelegate> *reflectionDelegate;
++    id <NSApplicationDelegate> reflectionDelegate;
+     bool inLaunch;
+ }
+ + (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
+@@ -122,7 +122,7 @@
+ - (QApplicationPrivate *)qAppPrivate;
+ - (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
+ - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
+-- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
++- (void)setReflectionDelegate:(id <NSApplicationDelegate>)oldDelegate;
+ - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
+ @end
+ #endif
 diff -ruN qt-4.8.6/src/gui/kernel/qcocoaapplication_mac.mm qt-4.8.6-new/src/gui/kernel/qcocoaapplication_mac.mm
 --- qt-4.8.6/src/gui/kernel/qcocoaapplication_mac.mm	2014-04-10 12:37:12.000000000 -0600
-+++ qt-4.8.6-new/src/gui/kernel/qcocoaapplication_mac.mm	2015-02-04 12:20:46.000000000 -0700
++++ qt-4.8.6-new/src/gui/kernel/qcocoaapplication_mac.mm	2015-03-08 04:49:48.931928450 -0600
 @@ -147,7 +147,7 @@
      if ([event type] == NSApplicationDefined) {
          switch ([event subtype]) {

                 [item setImage: nsimage];
diff -ruN qt-4.8.6/src/gui/widgets/qcocoamenu_mac.mm qt-4.8.6-new/src/gui/widgets/qcocoamenu_mac.mm
--- qt-4.8.6/src/gui/widgets/qcocoamenu_mac.mm	2014-04-10 12:37:12.000000000 -0600
+++ qt-4.8.6-new/src/gui/widgets/qcocoamenu_mac.mm	2015-02-04 12:20:46.000000000 -0700
@@ -202,7 +202,7 @@
      static SEL selForOFCP = NSSelectorFromString(@"orderFrontCharacterPalette:");
      if (index == -1 && selForOFCP == actionSelector) {

         QPoint qlocal, qglobal;
diff -ruN qt-4.8.6/src/gui/styles/qmacstyle_mac.mm qt-4.8.6-new/src/gui/styles/qmacstyle_mac.mm
--- qt-4.8.6/src/gui/styles/qmacstyle_mac.mm	2014-04-10 12:37:12.000000000 -0600
+++ qt-4.8.6-new/src/gui/styles/qmacstyle_mac.mm	2015-03-08 04:49:48.934928384 -0600
@@ -780,7 +780,7 @@
             if (!GetThemeMenuBarHeight(&size))
                 ret = QSize(-1, size);
