diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-03-08 12:40:28 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-03-09 12:11:47 +0100 |
commit | 2445d97a31d2fb3ee6580444a3541653f9fdb642 (patch) | |
tree | f001a32840e3749b934196d48520ef5ba70a581b /extensions | |
parent | 81c5d2f42afa6d0bf5a612770b7e4fee5ebf4d28 (diff) |
Make the CoInitializeEx() (non-)error reporting ludicrously verbose
Tell in the SAL_WARN what apartment mode the thread is in.
It's a bit unclear to me why the code insists on calling this
o2u_attachCurrentThread() function even in cases where it perhaps
should know that it is in the main thread, which has been initialised
as STA by the CoInitialize() in InitSalData().
Change-Id: Ia69e67f8b17ee153d3bcf8ae450d5f413dea2e1a
Reviewed-on: https://gerrit.libreoffice.org/50985
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/ole/olethread.cxx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/extensions/source/ole/olethread.cxx b/extensions/source/ole/olethread.cxx index 6bb0c5daab2a..3b35a802a5f8 100644 --- a/extensions/source/ole/olethread.cxx +++ b/extensions/source/ole/olethread.cxx @@ -19,6 +19,7 @@ #include "ole2uno.hxx" +#include <comphelper/windowserrorstring.hxx> #include <osl/thread.hxx> #include <sal/log.hxx> @@ -34,8 +35,31 @@ void o2u_attachCurrentThread() if (!SUCCEEDED(hr)) { // FIXME: is it a problem that this ends up in STA currently? assert(RPC_E_CHANGED_MODE == hr); - SAL_INFO("extensions.olebridge", - "CoInitializeEx fail: probably thread is in STA already?"); + // Let's find out explicitly what aprtment mode we are in. + SAL_WARN("extensions.olebridge", "CoInitializeEx failed" + << (hr == RPC_E_CHANGED_MODE ? " (expectedly)" : "") + << ": " << WindowsErrorStringFromHRESULT(hr)); + APTTYPE nAptType; + APTTYPEQUALIFIER nAptTypeQualifier; + if (SUCCEEDED(CoGetApartmentType(&nAptType, &nAptTypeQualifier))) + { + SAL_WARN("extensions.olebridge", + " Thread is in a " + << (nAptType == APTTYPE_STA ? OUString("single-threaded") : + (nAptType == APTTYPE_MTA ? OUString("multi-threaded") : + (nAptType == APTTYPE_NA ? OUString("neutral") : + (nAptType == APTTYPE_MAINSTA ? OUString("main single-threaded") : + ("unknown (") + OUString::number(nAptType) + ")")))) + << " apartment" + << (nAptTypeQualifier == APTTYPEQUALIFIER_NONE ? OUString() : + (nAptTypeQualifier == APTTYPEQUALIFIER_IMPLICIT_MTA ? OUString(" (implicit)") : + (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_MTA ? OUString(" (on MTA)") : + (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_STA ? OUString(" (on STA)") : + (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_IMPLICIT_MTA ? OUString(" (on implicit MTA)") : + (nAptTypeQualifier == APTTYPEQUALIFIER_NA_ON_MAINSTA ? OUString(" (on main STA)") : + (" (with unknown qualifier (" + OUString::number(nAptTypeQualifier) + "))"))))))) + << "."); + } } oleThreadData.setData(reinterpret_cast<void*>(true)); } |