summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2023-09-01 17:19:10 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2023-09-02 10:25:55 +0200
commit3115610cfa37b1341392039537299aea4a0b5d93 (patch)
tree3a6eda1bc8e5246dceaab97716d928a9c5211784 /src/tools
parent074c664b5c875d83d12df89dfa7a2f4b4af21285 (diff)
syncqt: Close ifstream before attempt to remove file
ifstream may block the file descriptor in some operating systems. Wrap the reading of files in staging directory with extra scope, to make sure that ifstream closed the descriptor before the removal attempt. Also make sure that we closed the ifstream explicitly. Pick-to: 6.5 6.6 Change-Id: I56ef5e9925501912d5cd61e8545f664e0a0d90b8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/syncqt/main.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tools/syncqt/main.cpp b/src/tools/syncqt/main.cpp
index 3f5fe50025..8d6709f981 100644
--- a/src/tools/syncqt/main.cpp
+++ b/src/tools/syncqt/main.cpp
@@ -740,9 +740,14 @@ public:
== m_producedHeaders.end()) {
// Check if header file came from another module as result of the cross-module
// deprecation before removing it.
- std::ifstream input(entry.path(), std::ifstream::in);
std::string firstLine;
- std::getline(input, firstLine);
+ {
+ std::ifstream input(entry.path(), std::ifstream::in);
+ if (input.is_open()) {
+ std::getline(input, firstLine);
+ input.close();
+ }
+ }
if (firstLine.find("#ifndef DEPRECATED_HEADER_"
+ m_commandLineArgs->moduleName())
== 0