From 719b5e95b448571df47498b4fffa2beb93c1a43f Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 4 Feb 2022 12:21:04 +0100 Subject: qdoc: DocBook: Fix incorrect static_cast in generateHeader() There was an incorrect cast from an Aggregate to a NamespaceNode without checking whether we in fact have a node representing a namespace. This resulted in a segfault under certain conditions, typically when generating output for a ProxyNode. Add a test for proxy page generation that (sporadically) resulted in a segfault before this fix. The test case itself is misusing QDoc commands to force a generation of a proxy page; this corner case will be addressed in a later patch to output a warning. Pick-to: 6.3 6.2 Fixes: QTBUG-100471 Change-Id: I4efff050a6be9a1305d97403b33e9e270e95a842 Reviewed-by: Luca Di Sera Reviewed-by: Paul Wicking --- .../proxypage-docbook/stdpair-proxy.xml | 21 +++++++++++++ .../expected_output/proxypage/stdpair-proxy.html | 20 +++++++++++++ .../generatedoutput/testdata/proxypage/proxy.h | 33 +++++++++++++++++++++ .../generatedoutput/testdata/proxypage/proxy.qdoc | 34 ++++++++++++++++++++++ .../testdata/proxypage/proxypage.qdocconf | 13 +++++++++ .../qdoc/generatedoutput/tst_generatedoutput.cpp | 8 +++++ 6 files changed, 129 insertions(+) create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/proxypage-docbook/stdpair-proxy.xml create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/proxypage/stdpair-proxy.html create mode 100644 tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.h create mode 100644 tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.qdoc create mode 100644 tests/auto/qdoc/generatedoutput/testdata/proxypage/proxypage.qdocconf (limited to 'tests') diff --git a/tests/auto/qdoc/generatedoutput/expected_output/proxypage-docbook/stdpair-proxy.xml b/tests/auto/qdoc/generatedoutput/expected_output/proxypage-docbook/stdpair-proxy.xml new file mode 100644 index 000000000..a9e26bd8e --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/proxypage-docbook/stdpair-proxy.xml @@ -0,0 +1,21 @@ + + + +StdPair +ProxyPage +ProxyPage Reference Documentation + +ProxyPage Reference Documentation. + + +Type Documentation + +[alias] template <class T1, class T2> StdPair + +StdPairpublic +active +unspecified + + + + diff --git a/tests/auto/qdoc/generatedoutput/expected_output/proxypage/stdpair-proxy.html b/tests/auto/qdoc/generatedoutput/expected_output/proxypage/stdpair-proxy.html new file mode 100644 index 000000000..2b7377e50 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/proxypage/stdpair-proxy.html @@ -0,0 +1,20 @@ + + + + + StdPair Proxy Page | ProxyPage + + +

StdPair Proxy Page

+

Types

+
+ +
StdPair
+
+

Type Documentation

+ +

[alias] template <class T1, class T2> StdPair

+ +
+ + diff --git a/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.h b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.h new file mode 100644 index 000000000..69a6af43f --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.h @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#pragma once + +#include + +template +using StdPair = std::pair; diff --git a/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.qdoc b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.qdoc new file mode 100644 index 000000000..7a681cbbd --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.qdoc @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + //! Misuse of QDoc commands that results in the generation of an orphaned + //! proxy page; Relate the topic command to itself. + \typealias StdPair + \relates StdPair +*/ diff --git a/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxypage.qdocconf b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxypage.qdocconf new file mode 100644 index 000000000..85f0ecd76 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testdata/proxypage/proxypage.qdocconf @@ -0,0 +1,13 @@ +include(../configs/config.qdocconf) + +project = ProxyPage +includepaths += . +moduleheader = proxy.h + +{sourcedirs,headerdirs} = . + +outputformats = HTML DocBook +{HTML.nosubdirs,DocBook.nosubdirs} = true +HTML.outputsubdir = proxypage +DocBook.outputsubdir = proxypage-docbook + diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index 73759b939..c53c10acc 100644 --- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp +++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp @@ -80,6 +80,7 @@ private slots: void properties(); void testTagFile(); void testGlobalFunctions(); + void proxyPage(); private: QScopedPointer m_outputDir; @@ -543,6 +544,13 @@ void tst_generatedOutput::testGlobalFunctions() testAndCompare("testdata/configs/testglobals.qdocconf", "globals.html"); } +void tst_generatedOutput::proxyPage() +{ + testAndCompare("testdata/proxypage/proxypage.qdocconf", + "proxypage/stdpair-proxy.html " + "proxypage-docbook/stdpair-proxy.xml"); +} + int main(int argc, char *argv[]) { tst_generatedOutput tc; -- cgit v1.2.1