summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-08-30 09:16:55 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-08-30 14:48:26 +0200
commit629dfff3c7289f185268c7088e67931f6bbd9ce0 (patch)
treefac587a2334338b6466a7e46f7ae3e949e9d7edb /sal
parent760a377f7148e623e9e16d24e66f54a401ecb946 (diff)
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>
Diffstat (limited to 'sal')
-rw-r--r--sal/Library_sal.mk1
-rw-r--r--sal/osl/unx/salinit.cxx6
-rw-r--r--sal/osl/unx/signal.cxx40
-rw-r--r--sal/osl/unx/soffice.cxx25
-rw-r--r--sal/osl/unx/soffice.hxx26
-rw-r--r--sal/osl/w32/salinit.cxx4
6 files changed, 64 insertions, 38 deletions
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index a02c333852b7..86f2158f039a 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -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 \
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index 81a2d02ca31e..9424089dbba0 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -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
diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index 085f14d8ec0c..55d09b4f6249 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -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
//
diff --git a/sal/osl/unx/soffice.cxx b/sal/osl/unx/soffice.cxx
new file mode 100644
index 000000000000..bcead388ba4c
--- /dev/null
+++ b/sal/osl/unx/soffice.cxx
@@ -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: */
diff --git a/sal/osl/unx/soffice.hxx b/sal/osl/unx/soffice.hxx
new file mode 100644
index 000000000000..da1b684af4ab
--- /dev/null
+++ b/sal/osl/unx/soffice.hxx
@@ -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: */
diff --git a/sal/osl/w32/salinit.cxx b/sal/osl/w32/salinit.cxx
index 77cb5da781e5..9b89cebc20ab 100644
--- a/sal/osl/w32/salinit.cxx
+++ b/sal/osl/w32/salinit.cxx
@@ -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);