QDoc: Match \include snippet names exactly
The \include command resolves named snippets by searching for
lines starting with "//!" that contain the requested identifier
as a substring. When one snippet name is a prefix of another,
such as "metadata" and "metadataReceived", QDoc silently includes
the wrong snippet if the longer name appears first in the file.
This can't be caught during authoring because the inclusion is
silent — the wrong content simply replaces the right content. The
bug became visible after QTBUG-117881 added parameter validation,
which now surfaces the wrong content as spurious "No such
parameter" warnings.
Exact matching against the bracket-delimited snippet name
eliminates the ambiguity regardless of declaration order or naming
conventions. A regression test confirms correct selection when a
shorter name is a prefix of a longer one.
Fixes: QTBUG-144451
Pick-to: 6.11 6.11.0
Change-Id: I0c50ad567923693f466ebac0528536bb7b858d2d
Reviewed-by: David Boddie <david.boddie@qt.io>
| commit | 03fde7daf50c2827923f8d07099f8a661a5dfe3e |
| parent | 2bbdf7cdbc77f4ec9d806166db64f795b52cebcb |
| author | Paul Wicking <paul.wicking@qt.io> |
| committer | Paul Wicking <paul.wicking@qt.io> |
| commit time | Wed, 25 Feb 2026 22:24:29 +0100 |
- M src/qdoc/qdoc/src/qdoc/docparser.cpp
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/expected/include-snippet-exact-match.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/expected/include-snippet-exact-match.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/expected/include-snippet-exact-match.xml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/expected/include_snippet_exact_match.index
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/include_snippet_exact_match.qdocconf
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/src/snippets.cpp
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/include_snippet_exact_match/src/test.qdoc