Unify inspector and console panel actions

This commit is contained in:
2026-03-27 00:08:46 +08:00
parent 31675e00c8
commit 3ebad63874
15 changed files with 296 additions and 142 deletions

View File

@@ -0,0 +1,51 @@
#pragma once
#include "Platform/Win32Utf8.h"
#include <stdio.h>
#include <string>
#include <windows.h>
namespace XCEngine {
namespace Editor {
namespace Platform {
inline std::string GetExecutableLogPath(const char* fileName) {
return GetExecutableDirectoryUtf8() + "\\" + fileName;
}
inline LONG WINAPI CrashExceptionFilter(EXCEPTION_POINTERS* exceptionPointers) {
const std::string logPath = GetExecutableLogPath("crash.log");
FILE* file = nullptr;
fopen_s(&file, logPath.c_str(), "a");
if (file) {
fprintf(
file,
"[CRASH] ExceptionCode=0x%08X, Address=0x%p\n",
exceptionPointers->ExceptionRecord->ExceptionCode,
exceptionPointers->ExceptionRecord->ExceptionAddress);
fclose(file);
}
fprintf(
stderr,
"[CRASH] ExceptionCode=0x%08X, Address=0x%p\n",
exceptionPointers->ExceptionRecord->ExceptionCode,
exceptionPointers->ExceptionRecord->ExceptionAddress);
return EXCEPTION_EXECUTE_HANDLER;
}
inline void InstallCrashExceptionFilter() {
SetUnhandledExceptionFilter(CrashExceptionFilter);
}
inline void RedirectStderrToExecutableLog() {
const std::string stderrPath = GetExecutableLogPath("stderr.log");
freopen(stderrPath.c_str(), "w", stderr);
}
} // namespace Platform
} // namespace Editor
} // namespace XCEngine