aboutsummaryrefslogtreecommitdiffstats
path: root/wireshark-qt.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-11-17 11:18:02 -0800
committerGerald Combs <gerald@wireshark.org>2017-11-17 20:26:27 +0000
commit658578a5b935d12c86b4181f9949da54a4ba7e0f (patch)
tree186abe7df044ad01658096cbd6c7d94564409c77 /wireshark-qt.cpp
parent71cec74ccb626edd6255d5bbf7cf95c01c32430b (diff)
Qt: Initialize QMimeDatabase in a worker thread.
As part of its initialization, QMimeDatabase parses the freedesktop.org shared-mime-info database, which is a large-ish (2 - 4 MB) XML file. This takes about 85 - 90 ms here. We first access QMimeDatabase in our startup sequence when we load the normal and capture application icons. Create a worker thread that initializes QMimeDatabase as early as possible and load load the normal and capture icons as late as possible. Change-Id: I27e3d65d8ee1308a62d12d3ff7e1b95f82c2e75a Reviewed-on: https://code.wireshark.org/review/24471 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'wireshark-qt.cpp')
-rw-r--r--wireshark-qt.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp
index a4341e5835..c1a5f27c62 100644
--- a/wireshark-qt.cpp
+++ b/wireshark-qt.cpp
@@ -96,6 +96,8 @@
#include "caputils/capture-pcap-util.h"
#include <QMessageBox>
+#include <QMimeDatabase>
+#include <QThread>
#ifdef _WIN32
# include "caputils/capture-wpcap.h"
@@ -138,6 +140,19 @@
*/
#define DEBUG_STARTUP_TIME_LOGLEVEL 252
+// QMimeDatabase can be slow to initialize. Do so in a worker thread
+// as early as possible.
+// https://github.com/lxde/pcmanfm-qt/issues/415
+class MimeDatabaseInitThread : public QThread
+{
+private:
+ void run()
+ {
+ QMimeDatabase mime_db;
+ mime_db.mimeTypeForData(QByteArray());
+ }
+};
+
/* update the main window */
void main_window_update(void)
{
@@ -380,6 +395,9 @@ int main(int argc, char *qt_argv[])
QTextCodec::setCodecForTr(utf8codec);
#endif
+ MimeDatabaseInitThread mime_db_init_thread;
+ mime_db_init_thread.start();
+
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");