mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Define only one crashCatcherInstall function
This commit is contained in:
parent
fc12728d25
commit
55501a02c0
@ -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…
Reference in New Issue
Block a user