From e76943ebb576ec9583f558dcec123bb9de4eaa23 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Fri, 17 Apr 2009 10:13:41 +0200
Subject: [PATCH] Load required dependency lib "dbghelp.dll" manually.

---
 src/plugins/debugger/cdb/cdbdebugengine.cpp   | 39 ++++++++++++++-----
 .../debugger/cdb/cdboptionspagewidget.ui      |  3 ++
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp
index d84d08dacfd..b210186c0f5 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.cpp
+++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp
@@ -65,6 +65,7 @@
 #define DBGHELP_TRANSLATE_TCHAR
 #include <inc/Dbghelp.h>
 
+static const char *dbgHelpDllC = "dbghelp";
 static const char *dbgEngineDllC = "dbgeng";
 static const char *debugCreateFuncC = "DebugCreate";
 
@@ -116,6 +117,12 @@ QString msgComFailed(const char *func, HRESULT hr)
 
 static const char *msgNoStackTraceC = "Internal error: no stack trace present.";
 
+static inline QString msgLibLoadFailed(const QString &lib, const QString &why)
+{
+    return CdbDebugEngine::tr("Unable to load the debugger engine library '%1': %2").
+            arg(lib, why);
+}
+
 // ----- Engine helpers
 
 static inline ULONG getInterruptTimeOutSecs(IDebugControl4 *ctl)
@@ -143,19 +150,31 @@ DebuggerEngineLibrary::DebuggerEngineLibrary() :
 {
 }
 
-bool DebuggerEngineLibrary::init(const QString &path, QString *errorMessage)
+// Build a lib name as "Path\x.dll"
+static inline QString libPath(const QString &libName, const QString &path = QString())
 {
-    // Load from path
-    QString dllPath = path;
-    if (!dllPath.isEmpty())
-        dllPath += QDir::separator();
-    dllPath += QLatin1String(dbgEngineDllC);
-
-    QLibrary lib(dllPath, 0);
+    QString rc = path;
+    if (!rc.isEmpty())
+        rc += QDir::separator();
+    rc += libName;
+    rc += QLatin1String(".dll");
+    return rc;
+}
 
+bool DebuggerEngineLibrary::init(const QString &path, QString *errorMessage)
+{
+    // Load the dependent help lib first
+    const QString helpLibPath = libPath(QLatin1String(dbgHelpDllC), path);
+    QLibrary helpLib(helpLibPath, 0);
+    if (!helpLib.isLoaded() && !helpLib.load()) {
+        *errorMessage = msgLibLoadFailed(helpLibPath, helpLib.errorString());
+        return false;
+    }
+    // Load dbgeng lib
+    const QString engineLibPath = libPath(QLatin1String(dbgEngineDllC), path);
+    QLibrary lib(engineLibPath, 0);
     if (!lib.isLoaded() && !lib.load()) {
-        *errorMessage = CdbDebugEngine::tr("Unable to load the debugger engine library '%1': %2").
-                        arg(QLatin1String(dbgEngineDllC), lib.errorString());
+        *errorMessage = msgLibLoadFailed(engineLibPath, lib.errorString());
         return false;
     }
     // Locate symbols
diff --git a/src/plugins/debugger/cdb/cdboptionspagewidget.ui b/src/plugins/debugger/cdb/cdboptionspagewidget.ui
index 9afbb318321..7afc74c1dde 100644
--- a/src/plugins/debugger/cdb/cdboptionspagewidget.ui
+++ b/src/plugins/debugger/cdb/cdboptionspagewidget.ui
@@ -18,6 +18,9 @@
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QGroupBox" name="cdbOptionsGroupBox">
+       <property name="toolTip">
+        <string>These options take effect at the next start of Qt Creator.</string>
+       </property>
        <property name="title">
         <string>CDB</string>
        </property>
-- 
GitLab