summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2023-01-16 09:31:24 +0000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-26 15:56:40 +0000
commite7208d6387c0f1f218d40d9c31a5eddf2cd6d038 (patch)
treece8107645e6348a4da3764470af9a3df9bd812cf
parent42c7f85b8fa2d0bc52302f508386763f31cd2742 (diff)
downloadqttools-e7208d6387c0f1f218d40d9c31a5eddf2cd6d038.tar.gz
qdoc: Ensure the generated temporary header file is closed properly
Use the correct scope for the QFile object used for writing the temporary header file; this ensures that the associated QTextStream object is destroyed first and its contents flushed before destroying the QFile, potentially leading to truncated writes to the file. Done-with: Simon Geisseler Fixes: QTBUG-109614 Change-Id: Ic6a68c0b52219ce607a5116c730862ee0cb37f04 Reviewed-by: Luca Di Sera <luca.disera@qt.io> (cherry picked from commit 0d8837c4103f941297adc3c76cb0ae6f67b6e34b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qdoc/clangcodeparser.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 93b63b7fb..0077117a3 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -1363,8 +1363,7 @@ void ClangCodeParser::buildPCH()
m_args.push_back("-xc++");
CXTranslationUnit tu;
QString tmpHeader = m_pchFileDir->path() + "/" + module;
- QFile tmpHeaderFile(tmpHeader);
- if (tmpHeaderFile.open(QIODevice::Text | QIODevice::WriteOnly)) {
+ if (QFile tmpHeaderFile(tmpHeader); tmpHeaderFile.open(QIODevice::Text | QIODevice::WriteOnly)) {
QTextStream out(&tmpHeaderFile);
if (header.isEmpty()) {
for (auto it = m_allHeaders.constKeyValueBegin();
@@ -1384,7 +1383,6 @@ void ClangCodeParser::buildPCH()
}
out << QLatin1String("#include \"") + header + QLatin1String("\"");
}
- tmpHeaderFile.close();
}
CXErrorCode err =