From 3a30a2fcb3f026ffba4d9484ad92479419d79547 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 19 Jan 2016 13:29:15 +0100 Subject: Allow QFinalStatePrivate to be subclassed. - put it in a separate private header - add a protected QFinalState constructor that takes a QFinalStatePrivate - when passing through, also export QStatePrivate, so the linker can find the symbol Change-Id: I8563da16739731d9d6142be438a8769fc29de148 Reviewed-by: Marc Mutz --- src/corelib/statemachine/qfinalstate.cpp | 26 +++++++----- src/corelib/statemachine/qfinalstate.h | 4 +- src/corelib/statemachine/qfinalstate_p.h | 68 +++++++++++++++++++++++++++++++ src/corelib/statemachine/qstate.cpp | 3 +- src/corelib/statemachine/qstate_p.h | 7 +++- src/corelib/statemachine/statemachine.pri | 1 + 6 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 src/corelib/statemachine/qfinalstate_p.h (limited to 'src/corelib/statemachine') diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp index ea96cc64c4..7e159ec1d1 100644 --- a/src/corelib/statemachine/qfinalstate.cpp +++ b/src/corelib/statemachine/qfinalstate.cpp @@ -31,12 +31,10 @@ ** ****************************************************************************/ -#include "qfinalstate.h" +#include "qfinalstate_p.h" #ifndef QT_NO_STATEMACHINE -#include "qabstractstate_p.h" - QT_BEGIN_NAMESPACE /*! @@ -76,19 +74,16 @@ QT_BEGIN_NAMESPACE \sa QState::finished() */ -class QFinalStatePrivate : public QAbstractStatePrivate -{ - Q_DECLARE_PUBLIC(QFinalState) - -public: - QFinalStatePrivate(); -}; - QFinalStatePrivate::QFinalStatePrivate() : QAbstractStatePrivate(FinalState) { } +QFinalStatePrivate::~QFinalStatePrivate() +{ + // to prevent vtables being generated in every file that includes the private header +} + /*! Constructs a new QFinalState object with the given \a parent state. */ @@ -97,6 +92,15 @@ QFinalState::QFinalState(QState *parent) { } +/*! + \internal + */ +QFinalState::QFinalState(QFinalStatePrivate &dd, QState *parent) + : QAbstractState(dd, parent) +{ +} + + /*! Destroys this final state. */ diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h index 2c76e7b6e6..74f73d559c 100644 --- a/src/corelib/statemachine/qfinalstate.h +++ b/src/corelib/statemachine/qfinalstate.h @@ -38,7 +38,6 @@ QT_BEGIN_NAMESPACE - #ifndef QT_NO_STATEMACHINE class QFinalStatePrivate; @@ -55,6 +54,9 @@ protected: bool event(QEvent *e) Q_DECL_OVERRIDE; +protected: + explicit QFinalState(QFinalStatePrivate &dd, QState *parent); + private: Q_DISABLE_COPY(QFinalState) Q_DECLARE_PRIVATE(QFinalState) diff --git a/src/corelib/statemachine/qfinalstate_p.h b/src/corelib/statemachine/qfinalstate_p.h new file mode 100644 index 0000000000..74640289f1 --- /dev/null +++ b/src/corelib/statemachine/qfinalstate_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFINALSTATE_P_H +#define QFINALSTATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qfinalstate.h" +#include "private/qabstractstate_p.h" + +#ifndef QT_NO_STATEMACHINE + +QT_BEGIN_NAMESPACE + +class Q_CORE_EXPORT QFinalStatePrivate : public QAbstractStatePrivate +{ + Q_DECLARE_PUBLIC(QFinalState) + +public: + QFinalStatePrivate(); + ~QFinalStatePrivate(); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_STATEMACHINE + +#endif // QFINALSTATE_P_H diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 3b84230cb2..cad524c720 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -31,11 +31,10 @@ ** ****************************************************************************/ -#include "qstate.h" +#include "qstate_p.h" #ifndef QT_NO_STATEMACHINE -#include "qstate_p.h" #include "qhistorystate.h" #include "qhistorystate_p.h" #include "qabstracttransition.h" diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 3b8dae9499..938822bcda 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -45,6 +45,7 @@ // We mean it. // +#include "qstate.h" #include "private/qabstractstate_p.h" #include @@ -52,6 +53,8 @@ #include #include +#ifndef QT_NO_STATEMACHINE + QT_BEGIN_NAMESPACE #ifndef QT_NO_PROPERTIES @@ -83,7 +86,7 @@ class QAbstractTransition; class QHistoryState; class QState; -class Q_AUTOTEST_EXPORT QStatePrivate : public QAbstractStatePrivate +class Q_CORE_EXPORT QStatePrivate : public QAbstractStatePrivate { Q_DECLARE_PUBLIC(QState) public: @@ -115,4 +118,6 @@ public: QT_END_NAMESPACE +#endif // QT_NO_STATEMACHINE + #endif diff --git a/src/corelib/statemachine/statemachine.pri b/src/corelib/statemachine/statemachine.pri index 910cf5e9b3..c5396a2ef8 100644 --- a/src/corelib/statemachine/statemachine.pri +++ b/src/corelib/statemachine/statemachine.pri @@ -6,6 +6,7 @@ HEADERS += $$PWD/qstatemachine.h \ $$PWD/qstate.h \ $$PWD/qstate_p.h \ $$PWD/qfinalstate.h \ + $$PWD/qfinalstate_p.h \ $$PWD/qhistorystate.h \ $$PWD/qhistorystate_p.h \ $$PWD/qabstracttransition.h \ -- cgit v1.2.3