diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-13 23:30:36 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-13 23:30:36 +0300 |
commit | 3ec9b8e0c27d42e3932a26da3221f78c6a5dc4e7 (patch) | |
tree | 868725cf4bffd18aa293b40a2d54d319919415b4 /source/creator/creator.c | |
parent | ab77466105ecd900dea69e9cf230c1a37fe1cc8c (diff) |
Purge temporary files on abort
This way both BLI_assert() and abort() called directly shouldn't
leave any files in the temp folder.
Previously it was really possible to have gadzillions of files
left over because of assert failures and debug aborts during the
development process.
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r-- | source/creator/creator.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c index 23a32af4dd0..4b523b66b04 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -195,6 +195,7 @@ static void setCallbacks(void); #ifndef WITH_PYTHON_MODULE static bool use_crash_handler = true; +static bool use_abort_handler = true; /* set breakpoints here when running in debug mode, useful to catch floating point errors */ #if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE) @@ -418,6 +419,12 @@ static int disable_crash_handler(int UNUSED(argc), const char **UNUSED(argv), vo return 0; } +static int disable_abort_handler(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + use_abort_handler = false; + return 0; +} + static int background_mode(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { G.background = 1; @@ -590,6 +597,11 @@ static void blender_crash_handler(int signum) #endif } +static void blender_abort_handler(int UNUSED(signum)) +{ + /* Delete content of temp dir! */ + BKE_tempdir_session_purge(); +} static int set_factory_startup(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { @@ -1354,6 +1366,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, "-Y", "--disable-autoexec", "\n\tDisable automatic python script execution (pydrivers & startup scripts)" PY_DISABLE_AUTO, disable_python, NULL); BLI_argsAdd(ba, 1, NULL, "--disable-crash-handler", "\n\tDisable the crash handler", disable_crash_handler, NULL); + BLI_argsAdd(ba, 1, NULL, "--disable-abort-handler", "\n\tDisable the abort handler", disable_abort_handler, NULL); #undef PY_ENABLE_AUTO #undef PY_DISABLE_AUTO @@ -1614,6 +1627,10 @@ int main( /* after parsing args */ signal(SIGSEGV, blender_crash_handler); } + + if (use_abort_handler) { + signal(SIGABRT, blender_abort_handler); + } #else G.factory_startup = true; /* using preferences or user startup makes no sense for py-as-module */ (void)syshandle; |