From 5a1fa8860ca466bc109f1195e1e4b92c0c92018d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 3 Sep 2012 12:55:38 +0200 Subject: Generate includes for Qt containers used as auto-metatypes. Otherwise the containers might be forward declared in the moc file, and when the moc file is compiled in a standalone translation unit, the full definition of it would not be available. This results in odd compile errors, so instead generate the includes if required. Change-Id: Ie01c5a5d45314daad0b00dec03b3e1e18cdbae64 Reviewed-by: Thiago Macieira Reviewed-by: Volker Krause Reviewed-by: Olivier Goffart --- tests/auto/tools/moc/forward-declared-param.h | 76 +++++++++++++++++++++++++++ tests/auto/tools/moc/moc.pro | 1 + 2 files changed, 77 insertions(+) create mode 100644 tests/auto/tools/moc/forward-declared-param.h (limited to 'tests') diff --git a/tests/auto/tools/moc/forward-declared-param.h b/tests/auto/tools/moc/forward-declared-param.h new file mode 100644 index 0000000000..9e0769f36c --- /dev/null +++ b/tests/auto/tools/moc/forward-declared-param.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Intel Corporation +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +// test support for const refs to forward-declared structs in parameters + +struct ForwardDeclaredParam; +template class ForwardDeclaredContainer; + +struct FullyDefined {}; +Q_DECLARE_METATYPE(FullyDefined) + +class ForwardDeclaredParamClass : public QObject +{ + Q_OBJECT +public slots: + void slotNaked(const ForwardDeclaredParam &) {} + void slotFDC(const ForwardDeclaredContainer &) {} + void slotFDC(const ForwardDeclaredContainer &) {} + void slotFDC(const ForwardDeclaredContainer &) {} + void slotFDC(const ForwardDeclaredContainer &) {} + void slotQSet(const QSet &) {} + void slotQSet(const QSet &) {} + void slotQSet(const QSet &) {} + void slotQSet(const QSet &) {} + +signals: + void signalNaked(const ForwardDeclaredParam &); + void signalFDC(const ForwardDeclaredContainer &); + void signalFDC(const ForwardDeclaredContainer &); + void signalFDC(const ForwardDeclaredContainer &); + void signalFDC(const ForwardDeclaredContainer &); + void signalQSet(const QSet &); + void signalQSet(const QSet &); + void signalQSet(const QSet &); + void signalQSet(const QSet &); +}; \ No newline at end of file diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index b3ed5df469..0932f5a471 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -21,6 +21,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \ cxx11-final-classes.h \ cxx11-explicit-override-control.h \ + forward-declared-param.h \ if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h -- cgit v1.2.3