From 3090534d92d598c4f6a1d758cc4392aa086a4c0a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 7 Sep 2021 03:57:06 +0200 Subject: kconfigini: Only open the file once to write We were calling open(), then fopen(), then QFile::open(). This patch removes the fopen() call that does not seem to do anything. --- src/core/kconfigini.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index 7c1e15f0..0e85cda7 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -510,19 +510,14 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa if (fd < 0) { return false; } - FILE *fp = ::fdopen(fd, "w"); - if (!fp) { - QT_CLOSE(fd); - return false; - } QFile f; - if (!f.open(fp, QIODevice::WriteOnly)) { - fclose(fp); + if (!f.open(fd, QIODevice::WriteOnly)) { + QT_CLOSE(fd); return false; } writeEntries(locale, f, writeMap); f.close(); - fclose(fp); + QT_CLOSE(fd); #else QFile f(filePath()); // XXX This is broken - it DOES create the file if it is suddenly gone. -- cgit v1.2.1