forked from osmocom/wireshark
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>
This commit is contained in:
parent
2acaf0a47a
commit
cf5a58f72a
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue