extensions/source/ole/olethread.cxx | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
New commits: commit 2445d97a31d2fb3ee6580444a3541653f9fdb642 Author: Tor Lillqvist <t...@collabora.com> Date: Thu Mar 8 12:40:28 2018 +0200 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 <c...@libreoffice.org> Reviewed-by: Tor Lillqvist <t...@collabora.com> 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)); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits