desktop/source/lib/init.cxx | 8 -------- pyuno/source/module/pyuno_module.cxx | 5 ----- sal/osl/unx/process_impl.cxx | 25 +++++++------------------ sal/osl/w32/process.cxx | 28 +++++++++++++--------------- 4 files changed, 20 insertions(+), 46 deletions(-)
New commits: commit b7d3c7c6a0c2562625c43e5dd1f2599a54a1d43e Author: Stephan Bergmann <[email protected]> Date: Wed Nov 26 14:40:34 2014 +0100 No need to call osl_setCommandArgs ...cf. 2ad716f406e0fdb9b9294876c64ae92fecbf5e27 "Revert 'pyuno: set up fake command line in getComponentContext()'" and 54981ce9286073306513fa58405ebc7730eb6dfb "Adapt some logs and assertions." Change-Id: I15229a29a3557b0490d7876b418dd24620ee4df5 (cherry picked from commit 2163ec3691ece9a00927891645190a971f775295) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fcef5b0..261b2f6 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -666,14 +666,6 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath) try { - // If we've set up the command args elsewhere then we cannot do it - // again (as an assert will fire), this will be the case e.g. - // for unit tests (and possibly if UNO is being used in addition - // to LOK in an external program). - if (!osl_areCommandArgsSet()) - { - osl_setCommandArgs(0, NULL); - } initialize_uno(aAppURL); force_c_locale(); commit 523a6710d0a28426f6f9747e1f401cf67b865c3a Author: Stephan Bergmann <[email protected]> Date: Tue Nov 25 23:35:47 2014 +0100 Adapt some logs and assertions ...cf. previous 2ad716f406e0fdb9b9294876c64ae92fecbf5e27 "Revert 'pyuno: set up fake command line in getComponentContext().'" Change-Id: Ia77132465ada17a5839f9d4f9ccaf20f8b113075 (cherry picked from commit 54981ce9286073306513fa58405ebc7730eb6dfb) diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 3942f14..0936b38 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -164,7 +164,9 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount (void) sal_uInt32 result = 0; pthread_mutex_lock (&(g_command_args.m_mutex)); - SAL_WARN_IF (g_command_args.m_nCount == 0, "sal.osl", "osl_setCommandArgs() not called before calling osl_getCommandArgCount()"); + SAL_INFO_IF( + g_command_args.m_nCount == 0, "sal.osl", + "osl_getCommandArgCount w/o prior call to osl_setCommandArgs"); if (g_command_args.m_nCount > 0) result = g_command_args.m_nCount - 1; pthread_mutex_unlock (&(g_command_args.m_mutex)); @@ -180,7 +182,7 @@ oslProcessError SAL_CALL osl_getCommandArg (sal_uInt32 nArg, rtl_uString ** strC oslProcessError result = osl_Process_E_NotFound; pthread_mutex_lock (&(g_command_args.m_mutex)); - OSL_ASSERT(g_command_args.m_nCount > 0); + assert(g_command_args.m_nCount > 0); if (g_command_args.m_nCount > (nArg + 1)) { rtl_uString_assign (strCommandArg, g_command_args.m_ppArgs[nArg + 1]); @@ -204,7 +206,7 @@ int SAL_CALL osl_areCommandArgsSet (void) **************************************/ void SAL_CALL osl_setCommandArgs (int argc, char ** argv) { - OSL_ASSERT(argc > 0); + assert(argc > 0); pthread_mutex_lock (&(g_command_args.m_mutex)); assert (g_command_args.m_nCount == 0); if (g_command_args.m_nCount == 0) diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 6db821b..23180af 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -28,11 +28,14 @@ #pragma warning(pop) #endif +#include <cassert> + #include <osl/diagnose.h> #include <osl/security.h> #include <osl/nlsupport.h> #include <osl/mutex.h> #include <osl/thread.h> +#include <sal/log.hxx> #include "getexecutablefile.hxx" #include "procimpl.h" @@ -268,7 +271,7 @@ static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) int i; int nArgs; LPWSTR *wargv = CommandLineToArgvW( GetCommandLineW(), &nArgs ); - OSL_ASSERT( nArgs == argc ); + assert( nArgs == argc ); for (i = 0; i < nArgs; i++) { /* Convert to unicode */ @@ -334,11 +337,9 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount(void) sal_uInt32 result = 0; osl_acquireMutex (*osl_getGlobalMutex()); - if (g_command_args.m_nCount == 0) { - OSL_TRACE( - OSL_LOG_PREFIX - "osl_getCommandArgCount w/o prior call to osl_setCommandArgs"); - } + SAL_INFO_IF( + g_command_args.m_nCount == 0, "sal.osl", + "osl_getCommandArgCount w/o prior call to osl_setCommandArgs"); if (g_command_args.m_nCount > 0) { /* We're not counting argv[0] here. */ @@ -356,7 +357,7 @@ oslProcessError SAL_CALL osl_getCommandArg( sal_uInt32 nArg, rtl_uString **strCo oslProcessError result = osl_Process_E_NotFound; osl_acquireMutex (*osl_getGlobalMutex()); - OSL_ASSERT(g_command_args.m_nCount > 0); + assert(g_command_args.m_nCount > 0); if (g_command_args.m_nCount > (nArg + 1)) { /* We're not counting argv[0] here. */ @@ -381,7 +382,7 @@ int SAL_CALL osl_areCommandArgsSet(void) void SAL_CALL osl_setCommandArgs (int argc, char ** argv) { - OSL_ASSERT(argc > 0); + assert(argc > 0); osl_acquireMutex (*osl_getGlobalMutex()); if (g_command_args.m_nCount == 0) { commit a9d194f6f51656aeb42c13223177cb42f4efa895 Author: Stephan Bergmann <[email protected]> Date: Tue Nov 25 23:22:13 2014 +0100 Revert "pyuno: set up fake command line in getComponentContext()" This reverts commit 2386a92c1e6e8ec263edb4dc4fdcfeaa4673ce1f and its follow-ups 1acaa577b67158c060d2f57414f7aea86504a489 "sal: add special handling of argc==0 to osl_setCommandArgs()" and 01f27b5e5d428cc3c4aeabdcbbb8204494fbd435 "sal: fix osl_setCommandArgs() on WNT." The situation that osl_getCommandArgCount is called without a prior call to osl_setCommandArgs should be considered as harmless and can legitimately not only happen in the pyuno case discussed in the reverted commits, but also in case binary UNO is bootstrapped from within a Java process, as happens in test-javanative in ure/source/uretest/Makefile. Change-Id: I2829db390e37dfe5daeda33a4c0659b7d35e565a (cherry picked from commit 2ad716f406e0fdb9b9294876c64ae92fecbf5e27) diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index e7ebb73..c2ca67b 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -27,7 +27,6 @@ #include <osl/module.hxx> #include <osl/thread.h> -#include <osl/process.h> #include <osl/file.hxx> #include <typelib/typedescription.hxx> @@ -250,10 +249,6 @@ static PyObject* getComponentContext( } else { - // cppu::defaultBootstrap_InitialComponentContext expects - // command line arguments to be present - osl_setCommandArgs(0, 0); // fake it - OUString iniFile; if( path.isEmpty() ) { diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 56c4925..3942f14 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -164,7 +164,7 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount (void) sal_uInt32 result = 0; pthread_mutex_lock (&(g_command_args.m_mutex)); - assert (g_command_args.m_nCount != 0); + SAL_WARN_IF (g_command_args.m_nCount == 0, "sal.osl", "osl_setCommandArgs() not called before calling osl_getCommandArgCount()"); if (g_command_args.m_nCount > 0) result = g_command_args.m_nCount - 1; pthread_mutex_unlock (&(g_command_args.m_mutex)); @@ -204,26 +204,13 @@ int SAL_CALL osl_areCommandArgsSet (void) **************************************/ void SAL_CALL osl_setCommandArgs (int argc, char ** argv) { - // special case for argc == 0: set up fake command line - int nArgs(argc ? argc : 1); + OSL_ASSERT(argc > 0); pthread_mutex_lock (&(g_command_args.m_mutex)); assert (g_command_args.m_nCount == 0); if (g_command_args.m_nCount == 0) { - rtl_uString** ppArgs = - (rtl_uString**)rtl_allocateZeroMemory(nArgs * sizeof(rtl_uString*)); - if (ppArgs != 0 && argc == 0) - { - // special case: set up fake command line - char const*const arg = - "this is just a fake and cheap imitation of a command line"; - rtl_string2UString(&ppArgs[0], - arg, rtl_str_getLength(arg), RTL_TEXTENCODING_ASCII_US, - OSTRING_TO_OUSTRING_CVTFLAGS); - g_command_args.m_nCount = nArgs; - g_command_args.m_ppArgs = ppArgs; - } - else if (ppArgs != 0) + rtl_uString** ppArgs = (rtl_uString**)rtl_allocateZeroMemory (argc * sizeof(rtl_uString*)); + if (ppArgs != 0) { rtl_TextEncoding encoding = osl_getThreadTextEncoding(); for (int i = 0; i < argc; i++) diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 786e299..6db821b 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -259,20 +259,16 @@ static struct CommandArgs_Impl g_command_args = #pragma warning( push ) #pragma warning( disable: 4100 ) #endif -static rtl_uString ** osl_createCommandArgs_Impl (int & argc, char **) +static rtl_uString ** osl_createCommandArgs_Impl (int argc, char **) { - int nArgs(0); - LPWSTR *wargv = CommandLineToArgvW( GetCommandLineW(), &nArgs ); - if (argc != nArgs) - { - assert(argc == 0 /* special case - faked */); - argc = nArgs; - } rtl_uString ** ppArgs = - (rtl_uString**)rtl_allocateZeroMemory(nArgs * sizeof(rtl_uString*)); + (rtl_uString**)rtl_allocateZeroMemory (argc * sizeof(rtl_uString*)); if (ppArgs != 0) { int i; + int nArgs; + LPWSTR *wargv = CommandLineToArgvW( GetCommandLineW(), &nArgs ); + OSL_ASSERT( nArgs == argc ); for (i = 0; i < nArgs; i++) { /* Convert to unicode */ @@ -385,6 +381,7 @@ int SAL_CALL osl_areCommandArgsSet(void) void SAL_CALL osl_setCommandArgs (int argc, char ** argv) { + OSL_ASSERT(argc > 0); osl_acquireMutex (*osl_getGlobalMutex()); if (g_command_args.m_nCount == 0) { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
