mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 15:06:41 +00:00
Define only one crashCatcherInstall function
This commit is contained in:
parent
fc12728d25
commit
55501a02c0
3 changed files with 7 additions and 16 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/files/conversion.hpp>
|
||||||
|
|
||||||
#include <SDL_messagebox.h>
|
#include <SDL_messagebox.h>
|
||||||
|
|
||||||
|
@ -506,14 +507,17 @@ static bool is_debugger_present()
|
||||||
|
|
||||||
void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& crashLogPath)
|
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) || !is_debugger_present())
|
||||||
{
|
{
|
||||||
if (argc == 2 && strcmp(argv[1], crash_switch) == 0)
|
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)
|
if (crashCatcherInstallHandlers(argv) == -1)
|
||||||
Log(Debug::Warning) << "Installing crash handler failed";
|
Log(Debug::Warning) << "Installing crash handler failed";
|
||||||
else
|
else
|
||||||
Log(Debug::Info) << "Crash handler installed";
|
Log(Debug::Info) << "Crash handler installed";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,7 @@
|
||||||
#define CRASHCATCHER_H
|
#define CRASHCATCHER_H
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) \
|
void crashCatcherInstall(int argc, char** argv, const std::filesystem::path& crashLogPath);
|
||||||
|| 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
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -352,8 +352,7 @@ int wrapApplication(int (*innerApplication)(int argc, char* argv[]), int argc, c
|
||||||
#else
|
#else
|
||||||
const std::string crashLogName = Misc::StringUtils::lowerCase(appName) + "-crash.log";
|
const std::string crashLogName = Misc::StringUtils::lowerCase(appName) + "-crash.log";
|
||||||
// install the crash handler as soon as possible.
|
// install the crash handler as soon as possible.
|
||||||
crashCatcherInstall(
|
crashCatcherInstall(argc, argv, std::filesystem::temp_directory_path() / crashLogName);
|
||||||
argc, argv, Files::pathToUnicodeString(std::filesystem::temp_directory_path() / crashLogName));
|
|
||||||
#endif
|
#endif
|
||||||
ret = innerApplication(argc, argv);
|
ret = innerApplication(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue