mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +12:00
Win32: Fix deadlock on std::cerr usage
This commit is contained in:
parent
51e1598e42
commit
b55f38290b
3 changed files with 30 additions and 4 deletions
|
@ -154,7 +154,7 @@ LOG_CHANNEL(q_debug, "QDEBUG");
|
||||||
{
|
{
|
||||||
utils::attach_console(utils::console_stream::std_err, true);
|
utils::attach_console(utils::console_stream::std_err, true);
|
||||||
|
|
||||||
std::cerr << fmt::format("RPCS3: %s\n", text);
|
utils::output_stderr(fmt::format("RPCS3: %s\n", text));
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
jit_announce(0, 0, "");
|
jit_announce(0, 0, "");
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,7 +174,7 @@ LOG_CHANNEL(q_debug, "QDEBUG");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << fmt::format("RPCS3: %s\n", text);
|
utils::output_stderr(fmt::format("RPCS3: %s\n", text));
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto show_report = [is_html, include_help_text](std::string_view text)
|
static auto show_report = [is_html, include_help_text](std::string_view text)
|
||||||
|
@ -277,7 +277,7 @@ struct fatal_error_listener final : logs::listener
|
||||||
utils::attach_console(utils::console_stream::std_err, false);
|
utils::attach_console(utils::console_stream::std_err, false);
|
||||||
|
|
||||||
// Output to error stream as is
|
// Output to error stream as is
|
||||||
std::cerr << _msg;
|
utils::output_stderr(_msg);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (IsDebuggerPresent())
|
if (IsDebuggerPresent())
|
||||||
|
@ -401,7 +401,7 @@ QCoreApplication* create_application(int& argc, char* argv[])
|
||||||
{
|
{
|
||||||
const std::string msg = fmt::format("The command line value %s for %s is not allowed. Please use a valid value for Qt::HighDpiScaleFactorRoundingPolicy.", arg_val, arg_rounding);
|
const std::string msg = fmt::format("The command line value %s for %s is not allowed. Please use a valid value for Qt::HighDpiScaleFactorRoundingPolicy.", arg_val, arg_rounding);
|
||||||
sys_log.error("%s", msg); // Don't exit with fatal error. The resulting dialog might be unreadable with dpi problems.
|
sys_log.error("%s", msg); // Don't exit with fatal error. The resulting dialog might be unreadable with dpi problems.
|
||||||
std::cerr << msg << std::endl;
|
utils::output_stderr(msg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
void attach_console([[maybe_unused]] int stream, [[maybe_unused]] bool open_console)
|
void attach_console([[maybe_unused]] int stream, [[maybe_unused]] bool open_console)
|
||||||
|
@ -34,6 +36,26 @@ namespace utils
|
||||||
{
|
{
|
||||||
[[maybe_unused]] const auto con_in = freopen("CONIN$", "r", stdin);
|
[[maybe_unused]] const auto con_in = freopen("CONIN$", "r", stdin);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void output_stderr(std::string_view str, bool with_endline)
|
||||||
|
{
|
||||||
|
if (with_endline)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::clog << str;
|
||||||
|
#else
|
||||||
|
std::cerr << str;
|
||||||
|
#endif
|
||||||
|
str = "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Flush seems broken on Windows (deadlocks)
|
||||||
|
std::clog << str;
|
||||||
|
#else
|
||||||
|
std::cerr << str;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
enum console_stream
|
enum console_stream
|
||||||
|
@ -10,4 +12,6 @@ namespace utils
|
||||||
};
|
};
|
||||||
|
|
||||||
void attach_console(int stream, bool open_console);
|
void attach_console(int stream, bool open_console);
|
||||||
|
|
||||||
|
void output_stderr(std::string_view str, bool with_endline = false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue