diff options
-rw-r--r-- | desktop/win32/source/loader.cxx | 33 | ||||
-rw-r--r-- | vcl/win/window/salframe.cxx | 39 |
2 files changed, 71 insertions, 1 deletions
diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx index 998eb189effc..bbc97a462724 100644 --- a/desktop/win32/source/loader.cxx +++ b/desktop/win32/source/loader.cxx @@ -218,6 +218,8 @@ int officeloader_impl(bool bAllowConsole) // read limit values from fundamental.override.ini unsigned int nMaxMemoryInMB = 0; bool bExcludeChildProcesses = true; + bool fallbackForMaxMemoryInMB = true; + bool fallbackForExcludeChildProcesses = true; const WCHAR* szIniFile = L"\\fundamental.override.ini"; const size_t nDirLen = wcslen(szIniDirectory); @@ -233,13 +235,44 @@ int officeloader_impl(bool bAllowConsole) std::ifstream aFile(szBootstrapIni); boost::property_tree::ini_parser::read_ini(aFile, pt); nMaxMemoryInMB = pt.get("Bootstrap.LimitMaximumMemoryInMB", nMaxMemoryInMB); + fallbackForMaxMemoryInMB = !pt.get_child_optional("Bootstrap.LimitMaximumMemoryInMB"); bExcludeChildProcesses = pt.get("Bootstrap.ExcludeChildProcessesFromLimit", bExcludeChildProcesses); + fallbackForExcludeChildProcesses + = !pt.get_child_optional("Bootstrap.ExcludeChildProcessesFromLimit"); } catch (...) { nMaxMemoryInMB = 0; } } + // For backwards compatibility, for now also try to read the values from bootstrap.ini if + // fundamental.override.ini does not provide them: + if (fallbackForMaxMemoryInMB || fallbackForExcludeChildProcesses) { + const WCHAR* szFallbackIniFile = L"\\bootstrap.ini"; + const size_t nFallbackDirLen = wcslen(szIniDirectory); + if (wcslen(szFallbackIniFile) + nFallbackDirLen < MAX_PATH) + { + WCHAR szBootstrapIni[MAX_PATH]; + wcscpy(szBootstrapIni, szIniDirectory); + wcscpy(&szBootstrapIni[nFallbackDirLen], szFallbackIniFile); + + try + { + boost::property_tree::ptree pt; + std::ifstream aFile(szBootstrapIni); + boost::property_tree::ini_parser::read_ini(aFile, pt); + if (fallbackForMaxMemoryInMB) { + nMaxMemoryInMB = pt.get("Win32.LimitMaximumMemoryInMB", nMaxMemoryInMB); + } + if (fallbackForExcludeChildProcesses) { + bExcludeChildProcesses = pt.get("Win32.ExcludeChildProcessesFromLimit", bExcludeChildProcesses); + } + } + catch (...) + { + } + } + } // create a Windows JobObject with a memory limit HANDLE hJobObject = nullptr; diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 121596eb5b8c..797b5a80fc14 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -32,6 +32,12 @@ #include <comphelper/windowserrorstring.hxx> +#include <fstream> +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/ini_parser.hpp> +#include <osl/file.hxx> +#include <osl/process.h> + #include <rtl/bootstrap.hxx> #include <rtl/character.hxx> #include <rtl/string.h> @@ -1948,7 +1954,38 @@ static bool EnableAttachThreadInputHack() { OUString s("$EnableAttachThreadInputHack"); rtl::Bootstrap::expandMacros(s); - const bool bEnabled = s == "true"; + bool bEnabled; + if (!s.isEmpty()) { + bEnabled = s == "true"; + } else { + // For backwards compatibility, for now also try to read the value from a [Win32] section of + // bootstrap.ini if it is not set as a boostrap variable: + bEnabled = false; + OUString aBootstrapUri; + if (osl_getProcessWorkingDir(&aBootstrapUri.pData) == osl_Process_E_None) { + aBootstrapUri += "/bootstrap.ini"; + + OUString aSystemFileName; + if (osl::FileBase::getSystemPathFromFileURL(aBootstrapUri, aSystemFileName) + == osl::FileBase::E_None + && aSystemFileName.getLength() <= MAX_PATH) + { + // this uses the Boost ini parser, instead of tools::Config, as we already use it to + // read other values from bootstrap.ini in desktop/win32/source/loader.cxx, because + // that watchdog process can't access LO libs. This way the handling is consistent. + try + { + boost::property_tree::ptree pt; + std::ifstream aFile(o3tl::toW(aSystemFileName.getStr())); + boost::property_tree::ini_parser::read_ini(aFile, pt); + bEnabled = pt.get("Win32.EnableAttachThreadInputHack", false); + } + catch (...) + { + } + } + } + } SAL_WARN_IF(bEnabled, "vcl", "AttachThreadInput hack is enabled. Watch out for deadlocks!"); return bEnabled; } |