summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-12-11 13:43:14 -0800
committerThiago Macieira <thiago.macieira@intel.com>2014-12-20 07:36:20 +0100
commitcfab93418689db9a6702af7a60b7d45fc4b63898 (patch)
tree2e3ad3b399ca9e78d193efec0385ed2fb4ef1790
parentd1d3c36e876464a9bae42565f086ded268ab5118 (diff)
Fix loading of the dbus-1 DLL built by MinGW on Windows
QLibrary does not append the version suffix on Windows by itself, since there's no established practice on how to do this. The MinGW builds of dbus-1 call it "libdbus-1-3.dll", so we need append the suffix ourselves. Unfortunately, other names like "dbus-1.dll" have been seen in the wild, so we need to try both basenames (Windows doesn't prepend the "lib" prefix). Both basenames work on Unix, so give "libdbus-1" on Unix since that will result in one fewer stat. Change-Id: I92506df5fd30c7674216568406bf86b25bf646b8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/dbus/qdbus_symbols.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp
index 8c642c8887..e475a23f48 100644
--- a/src/dbus/qdbus_symbols.cpp
+++ b/src/dbus/qdbus_symbols.cpp
@@ -84,14 +84,29 @@ bool qdbus_loadLibDBus()
triedToLoadLibrary = true;
static int majorversions[] = { 3, 2, -1 };
+ const QString baseNames[] = {
+#ifdef Q_OS_WIN
+ QStringLiteral("dbus-1"),
+#endif
+ QStringLiteral("libdbus-1")
+ };
+
lib->unload();
- lib->setFileName(QLatin1String("dbus-1"));
for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) {
- lib->setFileNameAndVersion(lib->fileName(), majorversions[i]);
- if (lib->load() && lib->resolve("dbus_connection_open_private"))
- return true;
+ for (uint j = 0; j < sizeof(baseNames) / sizeof(baseNames[0]); ++j) {
+#ifdef Q_OS_WIN
+ QString suffix;
+ if (majorversions[i] != -1)
+ suffix = QString::number(- majorversions[i]); // negative so it prepends the dash
+ lib->setFileName(baseNames[j] + suffix);
+#else
+ lib->setFileNameAndVersion(baseNames[j], majorversions[i]);
+#endif
+ if (lib->load() && lib->resolve("dbus_connection_open_private"))
+ return true;
- lib->unload();
+ lib->unload();
+ }
}
delete lib;