aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/wireshark_application.cpp32
-rw-r--r--wireshark-qt.cpp18
2 files changed, 27 insertions, 23 deletions
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index 6abd29e4df..4f30f55d6a 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -93,11 +93,15 @@
#include <QMainWindow>
#include <QMutableListIterator>
#include <QSocketNotifier>
-#include <QThread>
#include <QUrl>
#include <QColorDialog>
#include <qmath.h>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QMimeDatabase>
+#include <QThreadPool>
+#endif
+
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -115,6 +119,22 @@ static QHash<int, QList<QAction *> > removed_menu_groups_;
QString WiresharkApplication::window_title_separator_ = QString::fromUtf8(" " UTF8_MIDDLE_DOT " ");
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+
+// QMimeDatabase parses a large-ish XML file and 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 QRunnable
+{
+private:
+ void run()
+ {
+ QMimeDatabase mime_db;
+ mime_db.mimeTypeForData(QByteArray());
+ }
+};
+#endif
+
void
topic_action(topic_action_e action)
{
@@ -438,9 +458,6 @@ void WiresharkApplication::reloadLuaPluginsDelayed()
QTimer::singleShot(0, this, SIGNAL(reloadLuaPlugins()));
}
-// This should be the first icon we fetch. We delay loading it as much as
-// possible in order to allow time for MimeDatabaseInitThread in
-// wireshark-qt.cpp to do its work.
const QIcon &WiresharkApplication::normalIcon()
{
if (normal_icon_.isNull()) {
@@ -731,6 +748,11 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
wsApp = this;
setApplicationName("Wireshark");
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ MimeDatabaseInitThread *mime_db_init_thread = new(MimeDatabaseInitThread);
+ QThreadPool::globalInstance()->start(mime_db_init_thread);
+#endif
+
Q_INIT_RESOURCE(about);
Q_INIT_RESOURCE(i18n);
Q_INIT_RESOURCE(layout);
@@ -992,7 +1014,7 @@ void WiresharkApplication::clearDynamicMenuGroupItems()
void WiresharkApplication::initializeIcons()
{
// Do this as late as possible in order to allow time for
- // MimeDatabaseInitThread in wireshark-qt.cpp to do its work.
+ // MimeDatabaseInitThread to do its work.
QList<int> icon_sizes = QList<int>() << 16 << 24 << 32 << 48 << 64 << 128 << 256 << 512 << 1024;
foreach (int icon_size, icon_sizes) {
QString icon_path = QString(":/wsicon/wsicon%1.png").arg(icon_size);
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp
index 73c5153ca7..a4341e5835 100644
--- a/wireshark-qt.cpp
+++ b/wireshark-qt.cpp
@@ -96,8 +96,6 @@
#include "caputils/capture-pcap-util.h"
#include <QMessageBox>
-#include <QMimeDatabase>
-#include <QThreadPool>
#ifdef _WIN32
# include "caputils/capture-wpcap.h"
@@ -140,19 +138,6 @@
*/
#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 QRunnable
-{
-private:
- void run()
- {
- QMimeDatabase mime_db;
- mime_db.mimeTypeForData(QByteArray());
- }
-};
-
/* update the main window */
void main_window_update(void)
{
@@ -395,9 +380,6 @@ int main(int argc, char *qt_argv[])
QTextCodec::setCodecForTr(utf8codec);
#endif
- MimeDatabaseInitThread *mime_db_init_thread = new(MimeDatabaseInitThread);
- QThreadPool::globalInstance()->start(mime_db_init_thread);
-
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");