summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6f304944..e1a6b853 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -411,27 +411,39 @@ void setupPath()
::SetEnvironmentVariableW(L"PATH", newPath.c_str());
}
-static void preloadSsl()
+void preloadDll(const QString& filename)
{
- QString appPath = QDir::toNativeSeparators(QCoreApplication::applicationDirPath());
- if (GetModuleHandleA("libeay32.dll"))
- qWarning("libeay32.dll already loaded?!");
- else {
- QString libeay32 = appPath + "\\libeay32.dll";
- if (!QFile::exists(libeay32))
- qWarning("libeay32.dll not found: %s", qUtf8Printable(libeay32));
- else if (!LoadLibraryW(libeay32.toStdWString().c_str()))
- qWarning("failed to load: %s, %d", qUtf8Printable(libeay32), GetLastError());
+ qDebug().nospace() << "preloading " << filename;
+
+ if (!GetModuleHandleW(filename.toStdWString().c_str())) {
+ // already loaded, this can happen when "restarting" MO by switching
+ // instances, for example
+ return;
}
- if (GetModuleHandleA("ssleay32.dll"))
- qWarning("ssleay32.dll already loaded?!");
- else {
- QString ssleay32 = appPath + "\\ssleay32.dll";
- if (!QFile::exists(ssleay32))
- qWarning("ssleay32.dll not found: %s", qUtf8Printable(ssleay32));
- else if (!LoadLibraryW(ssleay32.toStdWString().c_str()))
- qWarning("failed to load: %s, %d", qUtf8Printable(ssleay32), GetLastError());
+
+ const auto appPath = QDir::toNativeSeparators(
+ QCoreApplication::applicationDirPath());
+
+ const auto dllPath = appPath + "\\" + filename;
+
+ if (!QFile::exists(dllPath)) {
+ qWarning().nospace() << dllPath << "not found";
+ return;
}
+
+ if (!LoadLibraryW(dllPath.toStdWString().c_str())) {
+ const auto e = GetLastError();
+
+ qWarning().nospace()
+ << "failed to load " << dllPath << ": "
+ << formatSystemMessage(e);
+ }
+}
+
+void preloadSsl()
+{
+ preloadDll("libeay32.dll");
+ preloadDll("ssleay32.dll");
}
static QString getVersionDisplayString()
@@ -443,15 +455,9 @@ int runApplication(MOApplication &application, SingleInstance &instance,
const QString &splashPath)
{
- qDebug("Starting Mod Organizer version %s revision %s", qUtf8Printable(getVersionDisplayString()),
-#if defined(HGID)
- HGID
-#elif defined(GITID)
- GITID
-#else
- "unknown"
-#endif
- );
+ qDebug().nospace()
+ << "Starting Mod Organizer version "
+ << getVersionDisplayString() << " revision " << GITID;
#if !defined(QT_NO_SSL)
preloadSsl();
@@ -460,6 +466,16 @@ int runApplication(MOApplication &application, SingleInstance &instance,
qDebug("non-ssl build");
#endif
+ {
+ Environment env;
+
+ for (const auto& m : env.loadedModules()) {
+ qInfo().nospace().noquote() << " . " << m.toString();
+ }
+
+ return 0;
+ }
+
QString dataPath = application.property("dataPath").toString();
qDebug("data path: %s", qUtf8Printable(dataPath));