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 <marc.mutz@kdab.com>
bb10
Erik Verbruggen 2016-01-19 13:29:15 +01:00
parent 97b448b152
commit 3a30a2fcb3
6 changed files with 94 additions and 15 deletions

View File

@ -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.
*/

View File

@ -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)

View File

@ -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

View File

@ -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"

View File

@ -45,6 +45,7 @@
// We mean it.
//
#include "qstate.h"
#include "private/qabstractstate_p.h"
#include <QtCore/qlist.h>
@ -52,6 +53,8 @@
#include <QtCore/qpointer.h>
#include <QtCore/qvariant.h>
#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

View File

@ -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 \