diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-11-27 11:48:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-11-27 11:58:22 +0100 |
commit | ad03461b2fc7df65116823ec0bee80e60e30393b (patch) | |
tree | 834bafd684855089a58f8db17f603e3a7d1f8a6e /sal/osl | |
parent | 0dd3b7697b912193b9a5daaf4d0991797db79de6 (diff) |
Make osl_getExecutableFile work even without a prior osl_setCommandArgs
After 2ad716f406e0fdb9b9294876c64ae92fecbf5e27 "Revert 'pyuno: set up fake
command line in getComponentContext(),'" e.g. PythonTest_sw_python would fail on
Windows, where WinSalGraphics::GetDevFontList (vcl/win/source/gdi/salgdi3.cxx)
calls osl_getExecutableFile and is itself called in a python process where
osl_setCommandArgs has not been set up.
This patch makes osl_getExecutableFile on all platforms if osl_setCommandArgs
has not (yet) been set fall back to the code that was
osl_bootstrap_getExecutableFile_Impl (which was called from
sal/rtl/bootstrap.cxx, which can now call osl_getExecutableFile).
Change-Id: I6c1bb59205041b3208c830a8b8406e28128b4566
(cherry picked from commit 41565560250294e22fc1c21bc4bab8286255d4cc)
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 37 | ||||
-rw-r--r-- | sal/osl/w32/process.cxx | 32 |
2 files changed, 28 insertions, 41 deletions
diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 0936b38948fe..7d8cc81aa655 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -34,7 +34,6 @@ #include "file_path_helper.hxx" #include "uunxapi.hxx" -#include "getexecutablefile.hxx" #include "nlsupport.hxx" #ifdef ANDROID @@ -44,9 +43,9 @@ #if defined(MACOSX) || defined(IOS) #include <mach-o/dyld.h> -oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( - rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() +namespace { + +oslProcessError SAL_CALL bootstrap_getExecutableFile(rtl_uString ** ppFileURL) { oslProcessError result = osl_Process_E_NotFound; @@ -83,12 +82,14 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( return (result); } +} + #else #include <dlfcn.h> -oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( - rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() +namespace { + +oslProcessError SAL_CALL bootstrap_getExecutableFile(rtl_uString ** ppFileURL) { oslProcessError result = osl_Process_E_NotFound; @@ -110,13 +111,11 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( } } - /* Fallback to ordinary osl_getExecutableFile(). */ - if (result == osl_Process_E_NotFound) - result = osl_getExecutableFile (ppFileURL); - return (result); } +} + #endif /*************************************** @@ -141,19 +140,17 @@ static struct CommandArgs_Impl g_command_args = **************************************/ oslProcessError SAL_CALL osl_getExecutableFile (rtl_uString ** ppustrFile) { - oslProcessError result = osl_Process_E_NotFound; - pthread_mutex_lock (&(g_command_args.m_mutex)); - OSL_ASSERT(g_command_args.m_nCount > 0); - if (g_command_args.m_nCount > 0) + if (g_command_args.m_nCount == 0) { - /* CommandArgs set. Obtain argv[0]. */ - rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]); - result = osl_Process_E_None; + pthread_mutex_unlock (&(g_command_args.m_mutex)); + return bootstrap_getExecutableFile(ppustrFile); } - pthread_mutex_unlock (&(g_command_args.m_mutex)); - return (result); + /* CommandArgs set. Obtain argv[0]. */ + rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]); + pthread_mutex_unlock (&(g_command_args.m_mutex)); + return osl_Process_E_None; } /*************************************** diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 23180afc62c2..49259e03410a 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -37,7 +37,6 @@ #include <osl/thread.h> #include <sal/log.hxx> -#include "getexecutablefile.hxx" #include "procimpl.h" #include "sockimpl.h" #include "file_url.h" @@ -205,18 +204,9 @@ oslProcessError SAL_CALL osl_joinProcessWithTimeout(oslProcess Process, const Ti return osl_error; } -/*************************************************************************** - * osl_bootstrap_getExecutableFile_Impl(). - * - * @internal - * @see rtl_bootstrap - * @see #i37371# - * - ***************************************************************************/ +namespace { -extern "C" oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( - rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() +oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL) { oslProcessError result = osl_Process_E_NotFound; @@ -242,6 +232,8 @@ extern "C" oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( return (result); } +} + /*************************************************************************** * Command Line Arguments. ***************************************************************************/ @@ -315,19 +307,17 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) oslProcessError SAL_CALL osl_getExecutableFile( rtl_uString **ppustrFile ) { - oslProcessError result = osl_Process_E_NotFound; - osl_acquireMutex (*osl_getGlobalMutex()); - OSL_ASSERT(g_command_args.m_nCount > 0); - if (g_command_args.m_nCount > 0) + if (g_command_args.m_nCount == 0) { - /* CommandArgs set. Obtain arv[0]. */ - rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]); - result = osl_Process_E_None; + osl_releaseMutex (*osl_getGlobalMutex()); + return bootstrap_getExecutableFile(ppustrFile); } - osl_releaseMutex (*osl_getGlobalMutex()); - return (result); + /* CommandArgs set. Obtain arv[0]. */ + rtl_uString_assign (ppustrFile, g_command_args.m_ppArgs[0]); + osl_releaseMutex (*osl_getGlobalMutex()); + return osl_Process_E_None; } /***************************************************************************/ |