diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index 0a06557e3a..39d076677c 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -21,6 +21,7 @@ #include #include +#include #include @@ -506,14 +507,17 @@ static bool is_debugger_present() void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& crashLogPath) { +#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) \ + || defined(__posix)) if ((argc == 2 && strcmp(argv[1], crash_switch) == 0) || !is_debugger_present()) { if (argc == 2 && strcmp(argv[1], crash_switch) == 0) - crash_handler(crashLogPath.c_str()); + crash_handler(Files::pathToUnicodeString(crashLogPath).c_str()); if (crashCatcherInstallHandlers(argv) == -1) Log(Debug::Warning) << "Installing crash handler failed"; else Log(Debug::Info) << "Crash handler installed"; } +#endif } diff --git a/components/crashcatcher/crashcatcher.hpp b/components/crashcatcher/crashcatcher.hpp index 3cd1480dd5..9dd1000385 100644 --- a/components/crashcatcher/crashcatcher.hpp +++ b/components/crashcatcher/crashcatcher.hpp @@ -2,19 +2,7 @@ #define CRASHCATCHER_H #include -#include -#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) \ - || defined(__posix)) -#define USE_CRASH_CATCHER 1 -#else -#define USE_CRASH_CATCHER 0 -#endif - -#if USE_CRASH_CATCHER -extern void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& crashLogPath); -#else -inline void crashCatcherInstall(int, char**, const std::string& crashLogPath) {} -#endif +void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& crashLogPath); #endif diff --git a/components/debug/debugging.cpp b/components/debug/debugging.cpp index 3be977657a..d170cf1929 100644 --- a/components/debug/debugging.cpp +++ b/components/debug/debugging.cpp @@ -352,8 +352,7 @@ int wrapApplication(int (*innerApplication)(int argc, char* argv[]), int argc, c #else const std::string crashLogName = Misc::StringUtils::lowerCase(appName) + "-crash.log"; // install the crash handler as soon as possible. - crashCatcherInstall( - argc, argv, Files::pathToUnicodeString(std::filesystem::temp_directory_path() / crashLogName)); + crashCatcherInstall(argc, argv, std::filesystem::temp_directory_path() / crashLogName); #endif ret = innerApplication(argc, argv); }