From b62180187757889de5ac5e4493d246b83b73bf60 Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Sat, 12 Dec 2020 11:27:51 +0000 Subject: [PATCH] Qt: fix crash when opening/saving IP map on Windows According to https://bugreports.qt.io/browse/QTBUG-20372 you need to close a QFile before calling fclose, otherwise it leads to an unexpected behavior. Let's duplicate the file handle to avoid this issue as suggested in https://stackoverflow.com/questions/9465727/convert-qfile-to-file Closes #17074 (cherry picked from commit 746051d09978626a704f2c6cba650c505fca65f1) --- ui/qt/endpoint_dialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp index a452f7e4b4..94f1bdfd7a 100644 --- a/ui/qt/endpoint_dialog.cpp +++ b/ui/qt/endpoint_dialog.cpp @@ -223,7 +223,8 @@ QUrl EndpointDialog::createMap(bool json_only) g_free(hosts); return QUrl(); } - FILE* fp = ws_fdopen(fd, "wb"); + // duplicate file descriptor as it is not allowed to perform a fclose before closing QFile + FILE* fp = ws_fdopen(ws_dup(fd), "wb"); if (fp == NULL) { QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file")); g_free(hosts);