summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2022-02-04 12:21:04 +0100
committerTopi Reinio <topi.reinio@qt.io>2022-02-04 15:32:34 +0100
commit719b5e95b448571df47498b4fffa2beb93c1a43f (patch)
treef40cfdbebf1fb24a280a1492f391c14169e49688 /tests
parent94f6991d4d9ccd9408847e1ecc1b77d94fffa865 (diff)
downloadqttools-719b5e95b448571df47498b4fffa2beb93c1a43f.tar.gz
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 <luca.disera@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/proxypage-docbook/stdpair-proxy.xml21
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/proxypage/stdpair-proxy.html20
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.h33
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/proxypage/proxy.qdoc34
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/proxypage/proxypage.qdocconf13
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp8
6 files changed, 129 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<db:article xmlns:db="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.2" xml:lang="en">
+<db:info>
+<db:title>StdPair</db:title>
+<db:productname>ProxyPage</db:productname>
+<db:titleabbrev>ProxyPage Reference Documentation</db:titleabbrev>
+<db:abstract>
+<db:para>ProxyPage Reference Documentation.</db:para></db:abstract>
+</db:info>
+<db:section xml:id="type documentation">
+<db:title>Type Documentation</db:title>
+<db:section xml:id="StdPair-typedef">
+<db:title>[alias] template &lt;class T1, class T2&gt; StdPair</db:title>
+<db:typedefsynopsis>
+<db:type>StdPair</db:type><db:synopsisinfo db:role="access">public</db:synopsisinfo>
+<db:synopsisinfo db:role="status">active</db:synopsisinfo>
+<db:synopsisinfo db:role="threadsafeness">unspecified</db:synopsisinfo>
+</db:typedefsynopsis>
+</db:section>
+</db:section>
+</db:article>
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 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>StdPair Proxy Page | ProxyPage</title>
+</head>
+<body>
+<h1 class="title">StdPair Proxy Page</h1>
+<h2 id="types">Types</h2>
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="stdpair-proxy.html#StdPair-typedef">StdPair</a></b></td></tr>
+</table></div>
+<div class="types">
+<h2>Type Documentation</h2>
+<!-- $$$StdPair -->
+<h3 class="fn" id="StdPair-typedef"><code>[alias] </code>template &lt;class T1, class T2&gt; <span class="name">StdPair</span></h3>
+<!-- @@@StdPair -->
+</div>
+</body>
+</html>
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 <utility>
+
+template <class T1, class T2>
+using StdPair = std::pair<T1, T2>;
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<QTemporaryDir> 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;