From 3705c1263d4d2232d5527361692d25a8519c222b Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 26 Sep 2013 12:16:39 +0200 Subject: Doc: Add docs for rvalue references and move constructors These members were introduced in 4.8, but left undocumented. Because we consider undocumented API to be internal, the members are \since 5.2. Change-Id: I52e2840a8cfaa7f59f410b3e2a06c0942ea06539 Reviewed-by: Jerome Pasion Reviewed-by: Stephen Kelly --- src/gui/kernel/qcursor.cpp | 8 ++++++++ src/gui/kernel/qkeysequence.cpp | 8 ++++++++ src/gui/kernel/qpalette.cpp | 8 ++++++++ 3 files changed, 24 insertions(+) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index d6287aef5c..a33b264704 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -153,6 +153,14 @@ QT_BEGIN_NAMESPACE \sa QWidget, {fowler}{GUI Design Handbook: Cursors} */ +/*! + \fn QCursor &QCursor::operator=(QCursor &&other) + + Move-assigns \a other to this QCursor instance. + + \since 5.2 +*/ + /*! \fn QPoint QCursor::pos(const QScreen *screen) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 16324b3659..1fcf1026d2 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -732,6 +732,14 @@ static const struct { \value FullScreen Toggle the window state to/from full screen. */ +/*! + \fn QKeySequence &QKeySequence::operator=(QKeySequence &&other) + + Move-assigns \a other to this QKeySequence instance. + + \since 5.2 +*/ + /*! \since 4.2 diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index b266d31c5c..00ab74e4e4 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -89,6 +89,14 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) whiteBrush, buttonBrush, buttonBrush); } +/*! + \fn QPalette &QPalette::operator=(QPalette &&other) + + Move-assigns \a other to this QPalette instance. + + \since 5.2 +*/ + /*! \fn const QColor &QPalette::color(ColorRole role) const -- cgit v1.2.3 From 999e5162ec3e86c9cb84c3ec95dfd0ba4b21277f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Sep 2013 12:14:32 +0200 Subject: QPA: Fix semantics of GUI event dispatcher ownership in platform plugins The QPlatformIntegration::guiThreadEventDispatcher() function acted as an accessor to event dispatchers created in the constructor of each platform plugin, but the logic and semantics of event-dispatcher handling in Qt itself (QCoreApplication/QGuiApplication) still assumed both ownership and control over the event dispatcher, such as when to create one, which one to create, and when to delete it. This conflicted with the explicit calls in the platform plugins to QGuiApplication::setEventDispatcher(), as well as left a possibility that the event-dispatcher created by the platform plugin would never be deleted, as none of the platform plugins actually took full ownership of the dispatcher and deleted it in its destructor. The integration function has now been renamed back to its old name, createEventDispatcher(), and acts as a factory function, leaving the logic and lifetime of event dispatcher to QtCoreApplication. The only platform left with creating the event-dispatcher in the constructor is QNX, where other parts of the platform relies on having an event-dispatcher before their initialization. We then need to manually take care of the ownership transfer, so that the event-dispatcher is still destroyed at some point. Change-Id: I113db97d2545ebda39ebdefa865e488d2ce9368b Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/kernel/qguiapplication.cpp | 26 +++++++++++--------------- src/gui/kernel/qguiapplication_p.h | 3 +-- src/gui/kernel/qplatformintegration.cpp | 22 ++++++++++++++-------- src/gui/kernel/qplatformintegration.h | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b242a3cc68..8e5c290cc6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1029,27 +1029,23 @@ void QGuiApplicationPrivate::createPlatformIntegration() } +/*! + Called from QCoreApplication::init() + + Responsible for creating an event dispatcher when QCoreApplication + decides that it needs one (because a custom one has not been set). +*/ void QGuiApplicationPrivate::createEventDispatcher() { + Q_ASSERT(!eventDispatcher); + if (platform_integration == 0) createPlatformIntegration(); - if (!eventDispatcher) { - QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher(); - setEventDispatcher(eventDispatcher); - } -} - -void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) -{ - Q_Q(QGuiApplication); - - if (!QCoreApplicationPrivate::eventDispatcher) { - QCoreApplicationPrivate::eventDispatcher = eventDispatcher; - QCoreApplicationPrivate::eventDispatcher->setParent(q); - threadData->eventDispatcher = eventDispatcher; - } + // The platform integration should not mess with the event dispatcher + Q_ASSERT(!eventDispatcher); + eventDispatcher = platform_integration->createEventDispatcher(); } #if defined(QT_DEBUG) && defined(Q_OS_LINUX) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 7a4a161476..91c63e54c5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -83,8 +83,7 @@ public: ~QGuiApplicationPrivate(); void createPlatformIntegration(); - void createEventDispatcher(); - void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher); + void createEventDispatcher() Q_DECL_OVERRIDE; virtual void notifyLayoutDirectionChange(); virtual void notifyActiveWindowChange(QWindow *previous); diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index dc775bcb61..3f93856349 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -231,17 +231,23 @@ QPlatformServices *QPlatformIntegration::services() const are never repositioned by the window manager. The default implementation returns true. */ - /*! - \fn QAbstractEventDispatcher *QPlatformIntegration::guiThreadEventDispatcher() const = 0 + \fn QAbstractEventDispatcher *QPlatformIntegration::createEventDispatcher() const = 0 + + Factory function for the GUI event dispatcher. The platform plugin should create + and return a QAbstractEventDispatcher subclass when this function is called. + + If the platform plugin for some reason creates the event dispatcher outside of + this function (for example in the constructor), it needs to handle the case + where this function is never called, ensuring that the event dispatcher is + still deleted at some point (typically in the destructor). + + Note that the platform plugin should never explicitly set the event dispatcher + itself, using QCoreApplication::setEventDispatcher(), but let QCoreApplication + decide when and which event dispatcher to create. - Accessor function for the event dispatcher. The platform plugin should create - an instance of the QAbstractEventDispatcher in its constructor and set it - on the application using QGuiApplicationPrivate::instance()->setEventDispatcher(). - The event dispatcher is owned by QGuiApplication, the accessor should return - a flat pointer. - \sa QGuiApplicationPrivate + \since 5.2 */ bool QPlatformIntegration::hasCapability(Capability cap) const diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 0204181ca6..0af74370b5 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -111,7 +111,7 @@ public: virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const; // Event dispatcher: - virtual QAbstractEventDispatcher *guiThreadEventDispatcher() const = 0; + virtual QAbstractEventDispatcher *createEventDispatcher() const = 0; //Deeper window system integrations virtual QPlatformFontDatabase *fontDatabase() const; -- cgit v1.2.3 From 56cd9cc2b085c1a2152831d47bb8fd9607d7500e Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 27 Sep 2013 21:53:12 +0200 Subject: Update QSessionManager and related classes documentation Update the Qt 4 documentation of QSessionManager to reflect the changes in Qt 5 Task-number: QTBUG-33528 Change-Id: I74286134155efc2781f9f6fc505fb6cf736d814e Reviewed-by: Martin Smith --- src/gui/kernel/qguiapplication.cpp | 4 +-- src/gui/kernel/qsessionmanager.cpp | 50 ++++++++++++++++++++------------------ src/gui/kernel/qstylehints.cpp | 2 +- 3 files changed, 30 insertions(+), 26 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 8e5c290cc6..bde8d99a1c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2935,7 +2935,7 @@ static inline void applyWindowCursor(const QList &l) restoreOverrideCursor(), otherwise the stack will never be emptied. Example: - \snippet code/src_gui_kernel_qapplication_x11.cpp 0 + \snippet code/src_gui_kernel_qguiapplication_x11.cpp 0 \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), QWidget::setCursor() @@ -2995,7 +2995,7 @@ QStyleHints *QGuiApplication::styleHints() This function must be called before creating the QGuiApplication object, like this: - \snippet code/src_gui_kernel_qapplication.cpp 6 + \snippet code/src_gui_kernel_qguiapplication.cpp 0 \sa desktopSettingsAware() */ diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp index 8cc8d3d961..c46dd5f55a 100644 --- a/src/gui/kernel/qsessionmanager.cpp +++ b/src/gui/kernel/qsessionmanager.cpp @@ -74,10 +74,11 @@ QT_BEGIN_NAMESPACE QSessionManager provides an interface between the application and the session manager so that the program can work well with the session manager. In Qt, session management requests for action are handled by the two - virtual functions QApplication::commitData() and QApplication::saveState(). - Both provide a reference to a session manager object as argument, to allow - the application to communicate with the session manager. The session - manager can only be accessed through these functions. + signals QGuiApplication::commitDataRequest() and + QGuiApplication::saveStateRequest(). Both provide a reference to a session + manager object as argument, to allow the application to communicate with + the session manager. The session manager can only be accessed through these + functions. No user interaction is possible \e unless the application gets explicit permission from the session manager. You ask for permission by calling @@ -94,7 +95,7 @@ QT_BEGIN_NAMESPACE setRestartHint(), setProperty(), requestPhase2(). See the respective function descriptions for further details. - \sa QApplication, {Session Management} + \sa QGuiApplication, {Session Management} */ @@ -151,7 +152,7 @@ QSessionManager::~QSessionManager() If the application has been restored from an earlier session, this identifier is the same as it was in the earlier session. - \sa sessionKey(), QApplication::sessionId() + \sa sessionKey(), QGuiApplication::sessionId() */ QString QSessionManager::sessionId() const { @@ -169,7 +170,7 @@ QString QSessionManager::sessionId() const The session key changes with every call of commitData() or saveState(). - \sa sessionId(), QApplication::sessionKey() + \sa sessionId(), QGuiApplication::sessionKey() */ QString QSessionManager::sessionKey() const { @@ -197,15 +198,15 @@ QString QSessionManager::sessionKey() const phase, you must tell the session manager that this has happened by calling cancel(). - Here's an example of how an application's QApplication::commitData() might - be implemented: + Here's an example of how an application's QGuiApplication::commitDataRequest() + might be implemented: - \snippet code/src_gui_kernel_qapplication.cpp 8 + \snippet code/src_gui_kernel_qguiapplication.cpp 8 If an error occurred within the application while saving its data, you may want to try allowsErrorInteraction() instead. - \sa QApplication::commitData(), release(), cancel() + \sa QGuiApplication::commitDataRequest(), release(), cancel() */ bool QSessionManager::allowsInteraction() { @@ -261,8 +262,9 @@ void QSessionManager::cancel() \note These flags are only hints, a session manager may or may not respect them. - We recommend setting the restart hint in QApplication::saveState() because - most session managers perform a checkpoint shortly after an application's + We recommend setting the restart hint in QGuiApplication::saveStateRequest() + because most session managers perform a checkpoint shortly after an + application's startup. \sa restartHint() @@ -291,12 +293,13 @@ QSessionManager::RestartHint QSessionManager::restartHint() const If the session manager is capable of restoring sessions it will execute \a command in order to restore the application. The command defaults to - \snippet code/src_gui_kernel_qapplication.cpp 9 + \snippet code/src_gui_kernel_qguiapplication.cpp 9 - The \c -session option is mandatory; otherwise QApplication cannot tell - whether it has been restored or what the current session identifier is. - See QApplication::isSessionRestored() and QApplication::sessionId() for - details. + The \c -session option is mandatory; otherwise QGuiApplication cannot + tell whether it has been restored or what the current session identifier + is. + See QGuiApplication::isSessionRestored() and + QGuiApplication::sessionId() for details. If your application is very simple, it may be possible to store the entire application state in additional command line options. This is usually a @@ -318,7 +321,7 @@ void QSessionManager::setRestartCommand(const QStringList &command) To iterate over the list, you can use the \l foreach pseudo-keyword: - \snippet code/src_gui_kernel_qapplication.cpp 10 + \snippet code/src_gui_kernel_qguiapplication.cpp 10 \sa setRestartCommand(), restartHint() */ @@ -344,7 +347,7 @@ void QSessionManager::setDiscardCommand(const QStringList &command) To iterate over the list, you can use the \l foreach pseudo-keyword: - \snippet code/src_gui_kernel_qapplication.cpp 11 + \snippet code/src_gui_kernel_qguiapplication.cpp 11 \sa setDiscardCommand(), restartCommand(), setRestartCommand() */ @@ -396,9 +399,10 @@ bool QSessionManager::isPhase2() const /*! Requests a second session management phase for the application. The - application may then return immediately from the QApplication::commitData() - or QApplication::saveState() function, and they will be called again once - most or all other applications have finished their session management. + application may then return immediately from the + QGuiApplication::commitDataRequest() or QApplication::saveStateRequest() + function, and they will be called again once most or all other + applications have finished their session management. The two phases are useful for applications such as the X11 window manager that need to store information about another application's windows and diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index a302f2186c..04ea9c27d5 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -106,7 +106,7 @@ int QStyleHints::mouseDoubleClickInterval() const and the current position (e.g. in the mouse move event) is \c currentPos, you can find out if a drag should be started with code like this: - \snippet code/src_gui_kernel_qapplication.cpp 7 + \snippet code/src_gui_kernel_qguiapplication.cpp 6 \sa startDragTime(), QPoint::manhattanLength(), {Drag and Drop} */ -- cgit v1.2.3