diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-05-22 07:44:45 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-05-22 07:46:17 +0200 |
commit | 508b95899d4764d879a01b3990e44ce849cd9abc (patch) | |
tree | 3dbb215480c98ee75b5aacc5e3d691e04d8ce8c8 /src/plugins/platforms/windows/qwindowscontext.cpp | |
parent | f2891be00808c82f5069661d60d8727fe28774b7 (diff) | |
parent | 5d2939344eb8fbd3c2115f52a7a8d47365bdf820 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Ia36e93771066d8abcf8123dbe2362c5c9d9260fc
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 63615dd4bf..322bae10aa 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -741,6 +741,27 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn, HWND_MESSAGE, NULL, (HINSTANCE)GetModuleHandle(0), NULL); } +#ifndef Q_OS_WINCE +// 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, comError.Error(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), + message, 0, NULL); + if (message) { + const QString result = QString::fromWCharArray(message).trimmed(); + LocalFree((HLOCAL)message); + return result; + } + if (const WORD wCode = comError.WCode()) + return QStringLiteral("IDispatch error #") + QString::number(wCode); + return QStringLiteral("Unknown error 0x0") + QString::number(comError.Error(), 16); +} +#endif // !Q_OS_WINCE + /*! \brief Common COM error strings. */ @@ -807,7 +828,7 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr) #ifndef Q_OS_WINCE _com_error error(hr); result += QByteArrayLiteral(" ("); - result += QString::fromWCharArray(error.ErrorMessage()).toLocal8Bit(); + result += errorMessageFromComError(error); result += ')'; #endif // !Q_OS_WINCE return result; @@ -876,7 +897,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, // TODO: Release/regrab mouse if a popup has mouse grab. return false; case QtWindows::DestroyEvent: - if (!platformWindow->testFlag(QWindowsWindow::WithinDestroy)) { + if (platformWindow && !platformWindow->testFlag(QWindowsWindow::WithinDestroy)) { qWarning() << "External WM_DESTROY received for " << platformWindow->window() << ", parent: " << platformWindow->window()->parent() << ", transient parent: " << platformWindow->window()->transientParent(); |