aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-12-15 10:59:11 -0800
committerGerald Combs <gerald@wireshark.org>2017-12-15 22:07:34 +0000
commitcf5a58f72a58c36744878cd6eb640de669341a55 (patch)
tree3fc099341d63d68bc08463cd414c5fa831144232
parent2acaf0a47a643ff929ecf9354d62a642794bbbd1 (diff)
Qt: Initialize QFontDatabase in a worker thread.
QFontDatabase uses an internal list of system fonts which might take a while to initialize depending on your platform and hardware. On my notebook here it takes about 45 to 50 ms. Create a worker thread for QFontDatabase initialization similar to QMimeDatabase. Change-Id: Ieff683b023537a6c104a80f2611ea1e966b65610 Reviewed-on: https://code.wireshark.org/review/24841 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/wireshark_application.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index af1f8e0..143cd65 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -98,6 +98,7 @@
#include <qmath.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QFontDatabase>
#include <QMimeDatabase>
#include <QThreadPool>
#endif
@@ -133,6 +134,16 @@ private:
mime_db.mimeTypeForData(QByteArray());
}
};
+
+// Populating the font database can be slow as well.
+class FontDatabaseInitThread : public QRunnable
+{
+private:
+ void run()
+ {
+ QFontDatabase font_db;
+ }
+};
#endif
void
@@ -751,6 +762,8 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
MimeDatabaseInitThread *mime_db_init_thread = new(MimeDatabaseInitThread);
QThreadPool::globalInstance()->start(mime_db_init_thread);
+ FontDatabaseInitThread *font_db_init_thread = new (FontDatabaseInitThread);
+ QThreadPool::globalInstance()->start(font_db_init_thread);
#endif
Q_INIT_RESOURCE(about);