diff --git a/CHANGELOG.md b/CHANGELOG.md index e0c72541..969aa638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- Fixed large amount of empty lines in the log file when the Wine process closes + unexpectedly. - Made the plugin and host detection slightly more robust. ## [1.1.4] - 2020-05-12 diff --git a/src/plugin/plugin-bridge.cpp b/src/plugin/plugin-bridge.cpp index 5f463605..5a7b1eb6 100644 --- a/src/plugin/plugin-bridge.cpp +++ b/src/plugin/plugin-bridge.cpp @@ -612,16 +612,19 @@ void PluginBridge::async_log_pipe_lines(patched_async_pipe& pipe, boost::asio::streambuf& buffer, std::string prefix) { boost::asio::async_read_until( - pipe, buffer, '\n', [&, prefix](const auto&, size_t) { + pipe, buffer, '\n', + [&, prefix](const boost::system::error_code& error, size_t) { + // When we get an error code then that likely means that the pipe + // has been clsoed and we have reached the end of the file + if (error.failed()) { + return; + } + std::string line; std::getline(std::istream(&buffer), line); logger.log(prefix + line); - // Not sure why, but this async read will keep reading a ton of - // empty lines after the Wine process crashes - if (vst_host.running()) { - async_log_pipe_lines(pipe, buffer, prefix); - } + async_log_pipe_lines(pipe, buffer, prefix); }); }