Fix plugin groups outside of Wine prefixes

Boost.Process's `boost::process::environment::at` throws when the
environment variable does not exist, as opposed to `operator[]` which
falls back to an empty value.
This commit is contained in:
Robbert van der Helm
2020-09-27 17:26:16 +02:00
parent 1ad9a2b4ab
commit ae402aa805
2 changed files with 13 additions and 2 deletions
+5
View File
@@ -8,6 +8,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fixed an initialization error when using plugin groups for plugins that are
installed outside of a Wine prefix.
### yabridgectl
- Resolve relative paths when adding plugin directories or when changing
+8 -2
View File
@@ -149,8 +149,14 @@ GroupHost::GroupHost(
// the first process will handle the connections for both yabridge
// instances.
const bp::environment host_env = set_wineprefix();
fs::path wine_prefix = host_env.at("WINEPREFIX").to_string();
if (host_env.at("WINEPREFIX").empty()) {
fs::path wine_prefix;
if (auto wine_prefix_envvar = host_env.find("WINEPREFIX");
wine_prefix_envvar != host_env.end()) {
// This is a bit ugly, but Boost.Process's environment does not have a
// graceful way to check for empty environment variables in const
// qualified environments
wine_prefix = wine_prefix_envvar->to_string();
} else {
// Fall back to `~/.wine` if this has not been set or detected. This
// would happen if the plugin's .dll file is not inside of a Wine
// prefix. If this happens, then the Wine instance will be launched in