Define only one crashCatcherInstall function

ini_importer_tests
elsid 11 months ago
parent fc12728d25
commit 55501a02c0
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -21,6 +21,7 @@
#include <unistd.h>
#include <components/debug/debuglog.hpp>
#include <components/files/conversion.hpp>
#include <SDL_messagebox.h>
@ -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
}

@ -2,19 +2,7 @@
#define CRASHCATCHER_H
#include <filesystem>
#include <string>
#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

@ -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);
}

Loading…
Cancel
Save