From 12a4db710e0e663741e239d76ffe4625e94dace2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 13 Jul 2014 13:43:49 +0200 Subject: Revert "Session management for OS X" Broke tst_QMenu::statusTip by closing the menu while it should not. (and therefore, a QTimer::singleShot that fires while following test are running is making the test fail) This reverts commit 50c04d631858639c630e85456e7e003a80e33493. Change-Id: Ib4ef8190f945b915fe268745cc64d471994c5e2d Reviewed-by: Richard J. Moore --- src/plugins/platforms/cocoa/cocoa.pro | 6 +- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 31 ++++----- src/plugins/platforms/cocoa/qcocoaintegration.h | 8 --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 --- .../platforms/cocoa/qcocoasessionmanager.cpp | 70 ------------------- src/plugins/platforms/cocoa/qcocoasessionmanager.h | 79 ---------------------- 6 files changed, 16 insertions(+), 186 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.cpp delete mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.h (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index b8befcd497..ad6cb3a1fc 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -41,8 +41,7 @@ OBJECTIVE_SOURCES += main.mm \ qcocoakeymapper.mm \ qcocoamimetypes.mm -SOURCES += messages.cpp \ - qcocoasessionmanager.cpp +SOURCES += messages.cpp HEADERS += qcocoaintegration.h \ qcocoatheme.h \ @@ -77,8 +76,7 @@ HEADERS += qcocoaintegration.h \ qcocoaintrospection.h \ qcocoakeymapper.h \ messages.h \ - qcocoamimetypes.h \ - qcocoasessionmanager.h + qcocoamimetypes.h contains(QT_CONFIG, opengl.*) { OBJECTIVE_SOURCES += qcocoaglcontext.mm diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 6c39f1eb5a..efe3269d42 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -1,6 +1,5 @@ /**************************************************************************** ** -** Copyright (C) 2013 Samuel Gaist ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** @@ -79,13 +78,11 @@ #import "qnswindowdelegate.h" #import "qcocoamenuloader.h" #include "qcocoaintegration.h" -#include "qcocoasessionmanager.h" #include #include #include #include #include -#include #include "qt_mac_p.h" #include @@ -219,17 +216,6 @@ static void cleanupCocoaApplicationDelegate() return NSTerminateNow; } - QGuiApplicationPrivate *qGuiAppPriv = QGuiApplicationPrivate::instance(); - -#ifndef QT_NO_SESSIONMANAGER - QSessionManagerPrivate *managerPrivate = static_cast(QObjectPrivate::get(qGuiAppPriv->session_manager)); - QCocoaSessionManager *cocoaSessionManager = static_cast(managerPrivate->platformSessionManager); - cocoaSessionManager->appCommitData(); - - if (cocoaSessionManager->wasCanceled()) - return NSTerminateCancel; -#endif - if ([self canQuit]) { if (!startedQuit) { startedQuit = true; @@ -253,7 +239,7 @@ static void cleanupCocoaApplicationDelegate() } } - if (qGuiAppPriv->threadData->eventLoops.isEmpty()) { + if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { // INVARIANT: No event loop is executing. This probably // means that Qt is used as a plugin, or as a part of a native // Cocoa application. In any case it should be fine to @@ -283,6 +269,10 @@ static void cleanupCocoaApplicationDelegate() application depends on. */ NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; + [eventManager setEventHandler:self + andSelector:@selector(appleEventQuit:withReplyEvent:) + forEventClass:kCoreEventClass + andEventID:kAEQuitApplication]; [eventManager setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass @@ -293,6 +283,7 @@ static void cleanupCocoaApplicationDelegate() - (void) removeAppleEventHandlers { NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; + [eventManager removeEventHandlerForEventClass:kCoreEventClass andEventID:kAEQuitApplication]; [eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL]; } @@ -339,8 +330,7 @@ static void cleanupCocoaApplicationDelegate() && [reflectionDelegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)]) return [reflectionDelegate applicationShouldTerminateAfterLastWindowClosed:sender]; - - return qApp->quitOnLastWindowClosed(); + return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together. } @@ -446,6 +436,13 @@ static void cleanupCocoaApplicationDelegate() QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString))); } +- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + Q_UNUSED(event); + Q_UNUSED(replyEvent); + [NSApp terminate:self]; +} + - (void)qtDispatcherToQAction:(id)sender { Q_UNUSED(sender); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 9942ac09cc..5ca2ccc571 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -141,14 +141,6 @@ public: void setToolbar(QWindow *window, NSToolbar *toolbar); NSToolbar *toolbar(QWindow *window) const; void clearToolbars(); - - void setWindow(NSWindow* nsWindow, QCocoaWindow *window); - QCocoaWindow *window(NSWindow *window); - -#ifndef QT_NO_SESSIONMANAGER - QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const; -#endif - private: static QCocoaIntegration *mInstance; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 49e602f45c..4be49ed68f 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -54,7 +54,6 @@ #include "qcocoainputcontext.h" #include "qcocoamimetypes.h" #include "qcocoaaccessibility.h" -#include "qcocoasessionmanager.h" #include #include @@ -417,13 +416,6 @@ QCocoaScreen *QCocoaIntegration::screenAtIndex(int index) return mScreens.at(index); } -#ifndef QT_NO_SESSIONMANAGER -QPlatformSessionManager *QCocoaIntegration::createPlatformSessionManager(const QString &id, const QString &key) const -{ - return new QCocoaSessionManager(id, key); -} -#endif - bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp deleted file mode 100644 index 9d0df65bc8..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Samuel Gaist -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT_NO_SESSIONMANAGER -#include -#include - -QT_BEGIN_NAMESPACE - -QCocoaSessionManager::QCocoaSessionManager(const QString &id, const QString &key) - : QPlatformSessionManager(id, key), - m_canceled(false) -{ -} - -QCocoaSessionManager::~QCocoaSessionManager() -{ -} - -void QCocoaSessionManager::cancel() -{ - m_canceled = true; -} - -bool QCocoaSessionManager::wasCanceled() const -{ - return m_canceled; -} - -QT_END_NAMESPACE - -#endif // QT_NO_SESSIONMANAGER diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.h b/src/plugins/platforms/cocoa/qcocoasessionmanager.h deleted file mode 100644 index fe9ba1d075..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasessionmanager.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Samuel Gaist -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCOCOASESSIONMANAGER_H -#define QCOCOASESSIONMANAGER_H - -// -// W A R N I N G -// ------------- -// -// This file is part of the QPA API and is not meant to be used -// in applications. Usage of this API may make your code -// source and binary incompatible with future versions of Qt. -// - -#ifndef QT_NO_SESSIONMANAGER - -#include - -QT_BEGIN_NAMESPACE - -class Q_GUI_EXPORT QCocoaSessionManager : public QPlatformSessionManager -{ -public: - QCocoaSessionManager(const QString &id, const QString &key); - virtual ~QCocoaSessionManager(); - - void cancel() Q_DECL_OVERRIDE; - bool wasCanceled() const; - -private: - bool m_canceled; - - Q_DISABLE_COPY(QCocoaSessionManager) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_SESSIONMANAGER - -#endif // QCOCOASESSIONMANAGER_H -- cgit v1.2.3