summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-01-30 23:34:18 +0000
committerGerald Combs <gerald@wireshark.org>2015-01-30 23:37:18 +0000
commite76e14074e5a9c46886ab3124a5649eabe7bfe99 (patch)
tree1c59c74c7b2de7f7d9a116033bb565be4b0d884f
parent9a3676accb141c64fa88b11683d6e0d663df125f (diff)
downloadwireshark-e76e14074e5a9c46886ab3124a5649eabe7bfe99.tar.gz
Qt: Fix library path reset.
g9a3676a reset the Qt library path *after* wsApp was instantiated, which is too late. Do so before QCoreApplication has a chance to do anything we might regret. Change-Id: Ibbdb69d1b7c0ea4bf1042e98a5bb5deba13e954e Reviewed-on: https://code.wireshark.org/review/6864 Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/wireshark_application.cpp25
-rw-r--r--wireshark-qt.cpp42
2 files changed, 38 insertions, 29 deletions
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index 677485ba0a..4288d26a89 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -479,31 +479,6 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
wsApp = this;
setApplicationName("Wireshark");
-#ifdef Q_OS_WIN
- // Try to avoid library search path collisions. QCoreApplication will
- // search QT_INSTALL_PREFIX/plugins for platform DLLs before searching
- // the application directory. If
- //
- // - You have Qt version 5.x.y installed in the default location
- // (C:\Qt\5.x) on your machine.
- //
- // and
- //
- // - You install Wireshark that was built on a machine with Qt version
- // 5.x.z installed in the default location.
- //
- // Qt5Core.dll will load qwindows.dll from your local C:\Qt\...\plugins
- // directory. This may not be compatible with qwindows.dll from that
- // same path on the build machine. We work around this by removing every
- // except our application directory.
-
- foreach (QString path, libraryPaths()) {
- if (path.compare(applicationDirPath())) {
- removeLibraryPath(path);
- }
- }
-#endif
-
Q_INIT_RESOURCE(about);
Q_INIT_RESOURCE(display_filter);
Q_INIT_RESOURCE(i18n);
diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp
index 6de3e4c54d..75ef28eb81 100644
--- a/wireshark-qt.cpp
+++ b/wireshark-qt.cpp
@@ -397,6 +397,36 @@ check_and_warn_user_startup(const QString &cf_name)
}
#endif
+#ifdef _WIN32
+// Try to avoid library search path collisions. QCoreApplication will
+// search QT_INSTALL_PREFIX/plugins for platform DLLs before searching
+// the application directory. If
+//
+// - You have Qt version 5.x.y installed in the default location
+// (C:\Qt\5.x) on your machine.
+//
+// and
+//
+// - You install Wireshark that was built on a machine with Qt version
+// 5.x.z installed in the default location.
+//
+// Qt5Core.dll will load qwindows.dll from your local C:\Qt\5.x\...\plugins
+// directory. This may not be compatible with qwindows.dll from that
+// same path on the build machine. At any rate, loading DLLs from paths
+// you don't control is ill-advised. We work around this by removing every
+// path except our application directory.
+
+static inline void
+reset_library_path(void)
+{
+ QString app_path = QDir(get_progfile_dir()).path();
+ foreach (QString path, QCoreApplication::libraryPaths()) {
+ QCoreApplication::removeLibraryPath(path);
+ }
+ QCoreApplication::addLibraryPath(app_path);
+}
+#endif
+
/* And now our feature presentation... [ fade to music ] */
int main(int argc, char *argv[])
{
@@ -465,15 +495,19 @@ int main(int argc, char *argv[])
}
}
- /* Create The Wireshark app */
- ws_app = new WiresharkApplication(argc, argv);
-
/*
* Attempt to get the pathname of the executable file.
*/
- /* init_progfile_dir_error = */ init_progfile_dir(QCoreApplication::applicationFilePath().toUtf8().constData(), NULL);
+ /* init_progfile_dir_error = */ init_progfile_dir(argv[0], main);
g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir());
+#ifdef _WIN32
+ reset_library_path();
+#endif
+
+ /* Create The Wireshark app */
+ ws_app = new WiresharkApplication(argc, argv);
+
/* initialize the funnel mini-api */
// xxx qtshark
//initialize_funnel_ops();