aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-04-01 17:01:06 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-04-01 15:18:47 +0000
commit5f758065ca0eac8e01e80342b59f3a10e18be8a3 (patch)
tree9d6263be99b8b30cf808e247e09507d413eec3bc /src
parent6c76553fb70b12cec178314e9d81d444a30b6f92 (diff)
Use _com_error::ErrorMessage() directly.
Remove the duplicated code that was used for Windows XP. Reverts commit f5aa8ff0c397014bd0445986c33cfb0d55f0d533. Task-number: QTBUG-51673 Task-number: QTBUG-35617 Change-Id: I269bd4708b7611a9f65097228bd1095963530404 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/winextras/qwinfunctions.cpp21
1 files changed, 1 insertions, 20 deletions
diff --git a/src/winextras/qwinfunctions.cpp b/src/winextras/qwinfunctions.cpp
index 08650d6..ad6430a 100644
--- a/src/winextras/qwinfunctions.cpp
+++ b/src/winextras/qwinfunctions.cpp
@@ -214,25 +214,6 @@ QRegion QtWin::fromHRGN(HRGN hrgn)
return region;
}
-// Re-engineered from the inline function _com_error::ErrorMessage().
-// We cannot use it directly since it uses swprintf_s(), which is not
-// present in the MSVCRT.DLL found on Windows XP (QTBUG-35617).
-static inline QString errorMessageFromComError(const _com_error &comError)
-{
- TCHAR *message = Q_NULLPTR;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, DWORD(comError.Error()), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
- reinterpret_cast<LPWSTR>(&message), 0, NULL);
- if (message) {
- const QString result = QString::fromWCharArray(message).trimmed();
- LocalFree(message);
- return result;
- }
- if (const WORD wCode = comError.WCode())
- return QStringLiteral("IDispatch error #") + QString::number(wCode);
- return QStringLiteral("Unknown error HRESULT(0x0)") + QString::number(comError.Error(), 16);
-}
-
/*!
\since 5.2
@@ -242,7 +223,7 @@ static inline QString errorMessageFromComError(const _com_error &comError)
QString QtWin::stringFromHresult(HRESULT hresult)
{
_com_error error(hresult);
- return errorMessageFromComError(error);
+ return QString::fromWCharArray(error.ErrorMessage());
}
/*!