mirror of https://github.com/WerWolv/ImHex.git
debug: Fixed application crashing on Windows if not console is attached
This commit is contained in:
parent
dd35a717b7
commit
4effa999b3
|
@ -171,17 +171,19 @@
|
||||||
|
|
||||||
void Window::initNative() {
|
void Window::initNative() {
|
||||||
// Attach to parent console if one exists
|
// Attach to parent console if one exists
|
||||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||||
|
|
||||||
// Redirect cin, cout and cerr to that console
|
// Redirect cin, cout and cerr to that console
|
||||||
freopen("CONIN$", "w", stdin);
|
freopen("CONIN$", "w", stdin);
|
||||||
freopen("CONOUT$", "w", stdout);
|
freopen("CONOUT$", "w", stdout);
|
||||||
freopen("CONERR$", "w", stderr);
|
freopen("CONERR$", "w", stderr);
|
||||||
setvbuf(stdin, nullptr, _IONBF, 0);
|
setvbuf(stdin, nullptr, _IONBF, 0);
|
||||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||||
|
|
||||||
|
fmt::print("\n");
|
||||||
|
}
|
||||||
|
|
||||||
fmt::print("\n");
|
|
||||||
|
|
||||||
// Enable color format specifiers in console
|
// Enable color format specifiers in console
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue