aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2020-03-27 18:03:22 +0100
committerAnders Broman <a.broman58@gmail.com>2020-04-06 06:07:15 +0000
commit8b7757811dc1a824d46748cca27818b480d0fbed (patch)
tree3d9d6e16b6a0ddb440e659a7ea45bc669de17810 /ui
parent44799c2e764c645104446cc308da6a5de859a7ae (diff)
Qt: fix endpoint map file creation and presentation
At least with Qt 5.12 on Debian/testing the following needs to be changed: - The temporary file name created for the endpoint map file needs to be retrieved at least once when the file is open to be available later on. - The temporary endpoint map file needs to remain on temporary storage because the external presentation process (web browser) needs to have access to it when it starts (asynchronously) and for as long as it needs. Change-Id: I554110a5a3ffa48b44575b1cb45f5971baac5e9c Reviewed-on: https://code.wireshark.org/review/36599 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/endpoint_dialog.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp
index bfd3217919..2a65ada89a 100644
--- a/ui/qt/endpoint_dialog.cpp
+++ b/ui/qt/endpoint_dialog.cpp
@@ -201,12 +201,17 @@ QUrl EndpointDialog::createMap(bool json_only)
hostlist_talker_t **hosts = (hostlist_talker_t **)g_ptr_array_free(hosts_arr, FALSE);
QTemporaryFile tf("ipmapXXXXXX.html");
- tf.setAutoRemove(false);
if (!tf.open()) {
QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file"));
g_free(hosts);
return QUrl();
}
+
+ //
+ // XXX - At least with Qt 5.12 retrieving the name only works when
+ // it has been retrieved at least once when the file is open.
+ //
+ QString tempfilename = tf.fileName();
int fd = tf.handle();
//
// XXX - QFileDevice.handle() can return -1, but can QTemporaryFile.handle()
@@ -215,14 +220,12 @@ QUrl EndpointDialog::createMap(bool json_only)
if (fd == -1) {
QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file"));
g_free(hosts);
- tf.remove();
return QUrl();
}
FILE* fp = ws_fdopen(fd, "wb");
if (fp == NULL) {
QMessageBox::warning(this, tr("Map file error"), tr("Unable to create temporary file"));
g_free(hosts);
- tf.remove();
return QUrl();
}
@@ -232,16 +235,15 @@ QUrl EndpointDialog::createMap(bool json_only)
g_free(err_str);
g_free(hosts);
fclose(fp);
- tf.remove();
return QUrl();
}
g_free(hosts);
if (fclose(fp) == EOF) {
QMessageBox::warning(this, tr("Map file error"), g_strerror(errno));
- tf.remove();
return QUrl();
}
+ tf.setAutoRemove(false);
return QUrl::fromLocalFile(tf.fileName());
}
@@ -250,9 +252,6 @@ void EndpointDialog::openMap()
QUrl map_file = createMap(false);
if (!map_file.isEmpty()) {
QDesktopServices::openUrl(map_file);
- QString source_file = map_file.toLocalFile();
- if (!source_file.isEmpty())
- QFile::remove(source_file);
}
}