summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-11-27 11:48:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-11-27 11:58:22 +0100
commitad03461b2fc7df65116823ec0bee80e60e30393b (patch)
tree834bafd684855089a58f8db17f603e3a7d1f8a6e /sal
parent0dd3b7697b912193b9a5daaf4d0991797db79de6 (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')
-rw-r--r--sal/inc/getexecutablefile.hxx44
-rw-r--r--sal/osl/unx/process_impl.cxx37
-rw-r--r--sal/osl/w32/process.cxx32
-rw-r--r--sal/rtl/bootstrap.cxx6
4 files changed, 30 insertions, 89 deletions
diff --git a/sal/inc/getexecutablefile.hxx b/sal/inc/getexecutablefile.hxx
deleted file mode 100644
index 9ebf872d97aa..000000000000
--- a/sal/inc/getexecutablefile.hxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SAL_INC_GETEXECUTABLEFILE_HXX
-#define INCLUDED_SAL_INC_GETEXECUTABLEFILE_HXX
-
-#include <sal/config.h>
-
-#include <osl/process.h>
-#include <rtl/ustring.h>
-#include <sal/types.h>
-
-/***************************************
- osl_bootstrap_getExecutableFile_Impl().
-
- @internal
- @see rtl_bootstrap
- @see #i37371#
-
- **************************************/
-
-extern "C" oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl (
- rtl_uString ** ppFileURL
-) SAL_THROW_EXTERN_C();
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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;
}
/***************************************************************************/
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index f24881953770..39b7665a0be4 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -42,8 +42,6 @@
#include <boost/unordered_map.hpp>
#include <list>
-#include "getexecutablefile.hxx"
-
#ifdef ANDROID
#include <osl/detail/android-bootstrap.h>
#endif
@@ -216,7 +214,7 @@ static bool getFromCommandLineArgs(
static void getExecutableDirectory_Impl (rtl_uString ** ppDirURL)
{
OUString fileName;
- osl_bootstrap_getExecutableFile_Impl (&(fileName.pData));
+ osl_getExecutableFile(&(fileName.pData));
sal_Int32 nDirEnd = fileName.lastIndexOf('/');
OSL_ENSURE(nDirEnd >= 0, "Cannot locate executable directory");
@@ -254,7 +252,7 @@ static OUString & getIniFileName_Impl()
}
else
{
- osl_bootstrap_getExecutableFile_Impl (&(fileName.pData));
+ osl_getExecutableFile(&(fileName.pData));
// get rid of a potential executable extension
OUString progExt = ".bin";