summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qlibrary_win.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2013-09-13 12:32:49 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 13:54:13 +0200
commit83bc5eb0e112fe0bf2d81aa0f4c50938015354f5 (patch)
tree511665163c1e140205547f6c9c05cc193ef7fa60 /src/corelib/plugin/qlibrary_win.cpp
parent5ffedd0495e341a14169458c31b2c9003f756dba (diff)
WinRT: QLibrary & plugin support
Avoid unsupported Win32 API while providing alternative codepaths for in-package library loading. Change-Id: Iaad059d6c94d0347cbaa8d9b9240806afcb29561 Done-with: Andrew Knight Done-with: Kamil Trzcinski Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/plugin/qlibrary_win.cpp')
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index 16445f1163..928f2c5eb1 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -67,9 +67,10 @@ QStringList QLibraryPrivate::prefixes_sys()
bool QLibraryPrivate::load_sys()
{
+#ifndef Q_OS_WINRT
//avoid 'Bad Image' message box
UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
-
+#endif
// We make the following attempts at locating the library:
//
// WinCE
@@ -108,7 +109,14 @@ bool QLibraryPrivate::load_sys()
}
Q_FOREACH (const QString &attempt, attempts) {
+#ifndef Q_OS_WINRT
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
+#else // Q_OS_WINRT
+ QString path = QDir::toNativeSeparators(QDir::current().relativeFilePath(fileName));
+ pHnd = LoadPackagedLibrary((LPCWSTR)path.utf16(), 0);
+ if (pHnd)
+ qualifiedFileName = attempt;
+#endif // !Q_OS_WINRT
// If we have a handle or the last error is something other than "unable
// to find the module", then bail out
@@ -116,13 +124,16 @@ bool QLibraryPrivate::load_sys()
break;
}
+#ifndef Q_OS_WINRT
SetErrorMode(oldmode);
+#endif
if (!pHnd) {
errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qt_error_string());
} else {
// Query the actual name of the library that was loaded
errorString.clear();
+#ifndef Q_OS_WINRT
wchar_t buffer[MAX_PATH];
::GetModuleFileName(pHnd, buffer, MAX_PATH);
@@ -133,6 +144,7 @@ bool QLibraryPrivate::load_sys()
qualifiedFileName = moduleFileName;
else
qualifiedFileName = dir.filePath(moduleFileName);
+#endif // !Q_OS_WINRT
}
return (pHnd != 0);
}