Replace is_soffice_Impl hack with a better(?) hack
...that involves adding a second, one-off special meaning to the existing sal_detail_initialize function. This at least gets rid of the "osl_getExecutableFile contains 'soffice' substring" guesswork (and of the osl_systemPathGetFileNameOrLastDirectoryPart call there, which is what I'm actually after, for a different change to come). Change-Id: I4dd6eef1fd0411bf66943ffea415876c92d08526 Reviewed-on: https://gerrit.libreoffice.org/78291 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
760a377f71
commit
629dfff3c7
8 changed files with 74 additions and 38 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <osl/file.hxx>
|
||||
#include <rtl/bootstrap.hxx>
|
||||
#include <sal/log.hxx>
|
||||
#include <sal/main.h>
|
||||
#include <tools/extendapplicationenvironment.hxx>
|
||||
#include <vcl/glxtestprocess.hxx>
|
||||
#include <vcl/svmain.hxx>
|
||||
|
@ -108,6 +109,8 @@ static bool dumpCallback(const wchar_t* path, const wchar_t* id,
|
|||
#endif
|
||||
extern "C" int DESKTOP_DLLPUBLIC soffice_main()
|
||||
{
|
||||
sal_detail_initialize(sal::detail::InitializeSoffice, nullptr);
|
||||
|
||||
#if HAVE_FEATURE_BREAKPAD
|
||||
|
||||
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
|
||||
|
|
|
@ -33,6 +33,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
|
||||
// Special token for sal_detail_initialize argc parameter, used by the soffice.bin process to tell
|
||||
// SAL that it is running as part of that process (see sal/osl/unx/soffice.hxx); argv should be null
|
||||
// in such a sal_detail_initialize call:
|
||||
namespace sal::detail { constexpr int InitializeSoffice = -1; }
|
||||
#endif
|
||||
|
||||
SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
|
||||
SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize(void);
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ $(eval $(call gb_Library_add_exception_objects,sal,\
|
|||
sal/osl/unx/security \
|
||||
sal/osl/unx/signal \
|
||||
sal/osl/unx/socket \
|
||||
sal/osl/unx/soffice \
|
||||
sal/osl/unx/tempfile \
|
||||
sal/osl/unx/thread \
|
||||
sal/osl/unx/time \
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <sal/types.h>
|
||||
|
||||
#include "saltime.hxx"
|
||||
#include "soffice.hxx"
|
||||
#include <salusesyslog.hxx>
|
||||
|
||||
#if HAVE_SYSLOG_H
|
||||
|
@ -45,6 +46,11 @@
|
|||
extern "C" {
|
||||
|
||||
void sal_detail_initialize(int argc, char ** argv) {
|
||||
if (argc == sal::detail::InitializeSoffice)
|
||||
{
|
||||
sal::detail::setSoffice();
|
||||
return;
|
||||
}
|
||||
#if defined MACOSX && !HAVE_FEATURE_MACOSX_SANDBOX
|
||||
// On macOS when not sandboxed, soffice can restart itself via exec (see
|
||||
// restartOnMac in desktop/source/app/app.cxx), which leaves all file
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <config_features.h>
|
||||
|
||||
#include "soffice.hxx"
|
||||
/* system headers */
|
||||
#include "system.hxx"
|
||||
|
||||
|
@ -54,8 +55,6 @@
|
|||
|
||||
#include <osl/diagnose.h>
|
||||
#include <osl/signal.h>
|
||||
#include <osl/process.h>
|
||||
#include <osl/thread.h>
|
||||
#include <sal/log.hxx>
|
||||
#include <sal/macros.h>
|
||||
#include <rtl/bootstrap.h>
|
||||
|
@ -155,41 +154,6 @@ bool bSetILLHandler = false;
|
|||
|
||||
void signalHandlerFunction(int, siginfo_t *, void *);
|
||||
|
||||
void getExecutableName_Impl (rtl_String ** ppstrProgName)
|
||||
{
|
||||
rtl_uString* ustrProgFile = nullptr;
|
||||
osl_getExecutableFile (&ustrProgFile);
|
||||
if (ustrProgFile)
|
||||
{
|
||||
rtl_uString * ustrProgName = nullptr;
|
||||
osl_systemPathGetFileNameOrLastDirectoryPart (ustrProgFile, &ustrProgName);
|
||||
if (ustrProgName != nullptr)
|
||||
{
|
||||
rtl_uString2String (
|
||||
ppstrProgName,
|
||||
rtl_uString_getStr (ustrProgName), rtl_uString_getLength (ustrProgName),
|
||||
osl_getThreadTextEncoding(),
|
||||
OUSTRING_TO_OSTRING_CVTFLAGS);
|
||||
rtl_uString_release (ustrProgName);
|
||||
}
|
||||
rtl_uString_release (ustrProgFile);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_soffice_Impl()
|
||||
{
|
||||
sal_Int32 idx = -1;
|
||||
rtl_String* strProgName = nullptr;
|
||||
|
||||
getExecutableName_Impl (&strProgName);
|
||||
if (strProgName)
|
||||
{
|
||||
idx = rtl_str_indexOfStr (rtl_string_getStr (strProgName), "soffice");
|
||||
rtl_string_release (strProgName);
|
||||
}
|
||||
return (idx != -1);
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_BREAKPAD
|
||||
bool is_unset_signal(int signal)
|
||||
{
|
||||
|
@ -208,7 +172,7 @@ bool is_unset_signal(int signal)
|
|||
|
||||
bool onInitSignal()
|
||||
{
|
||||
if (is_soffice_Impl())
|
||||
if (sal::detail::isSoffice())
|
||||
{
|
||||
// WORKAROUND FOR SEGV HANDLER CONFLICT
|
||||
//
|
||||
|
|
25
sal/osl/unx/soffice.cxx
Normal file
25
sal/osl/unx/soffice.cxx
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "soffice.hxx"
|
||||
|
||||
namespace
|
||||
{
|
||||
std::atomic<bool> flag(false);
|
||||
}
|
||||
|
||||
void sal::detail::setSoffice() { flag = true; }
|
||||
|
||||
bool sal::detail::isSoffice() { return flag; }
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
26
sal/osl/unx/soffice.hxx
Normal file
26
sal/osl/unx/soffice.hxx
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SAL_OSL_UNX_SOFFICE_HXX
|
||||
#define INCLUDED_SAL_OSL_UNX_SOFFICE_HXX
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
// Used to communicate special sal::detail::InitializeSoffice sal_detail_initialize call:
|
||||
|
||||
namespace sal::detail
|
||||
{
|
||||
void setSoffice();
|
||||
|
||||
bool isSoffice();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
|
@ -32,6 +32,10 @@ extern "C" {
|
|||
|
||||
void sal_detail_initialize(int argc, char ** argv)
|
||||
{
|
||||
if (argc == sal::detail::InitializeSoffice)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sal_initGlobalTimer();
|
||||
#ifndef _WIN64
|
||||
SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
|
||||
|
|
Loading…
Reference in a new issue