forked from bartvdbraak/blender
Cleanup: pass the exit-code to WM_exit
Callers to WM_exit needed to set G.is_break for a predictable exit-code. This is error prone as G.is_break may be set based on the user having pressed escape during event handling. Instead, pass the exit code as an argument.
This commit is contained in:
parent
be4a9fe4df
commit
d7d1c524e3
@ -429,8 +429,7 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||
{
|
||||
#if 0
|
||||
G.is_break = false; /* Let Cocoa perform the termination at the end. */
|
||||
WM_exit(C);
|
||||
WM_exit(C, EXIT_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,11 @@ void WM_exit_ex(struct bContext *C, bool do_python);
|
||||
* \brief Main exit function to close Blender ordinarily.
|
||||
* \note Use #wm_exit_schedule_delayed() to close Blender from an operator.
|
||||
* Might leak memory otherwise.
|
||||
*
|
||||
* \param exit_code: Passed to #exit, typically #EXIT_SUCCESS or #EXIT_FAILURE should be used.
|
||||
* With failure being used for an early exit when parsing command line arguments fails.
|
||||
*/
|
||||
void WM_exit(struct bContext *C) ATTR_NORETURN;
|
||||
void WM_exit(struct bContext *C, int exit_code) ATTR_NORETURN;
|
||||
|
||||
void WM_main(struct bContext *C) ATTR_NORETURN;
|
||||
|
||||
|
@ -450,10 +450,7 @@ static void wait_for_console_key(void)
|
||||
|
||||
static int wm_exit_handler(bContext *C, const wmEvent *event, void *userdata)
|
||||
{
|
||||
/* Prevent a non-zero exit code (if escape was pressed by the user). */
|
||||
G.is_break = false;
|
||||
|
||||
WM_exit(C);
|
||||
WM_exit(C, EXIT_SUCCESS);
|
||||
|
||||
UNUSED_VARS(event, userdata);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
@ -693,7 +690,7 @@ void WM_exit_ex(bContext *C, const bool do_python)
|
||||
CLG_exit();
|
||||
}
|
||||
|
||||
void WM_exit(bContext *C)
|
||||
void WM_exit(bContext *C, const int exit_code)
|
||||
{
|
||||
WM_exit_ex(C, true);
|
||||
|
||||
@ -707,7 +704,7 @@ void WM_exit(bContext *C)
|
||||
}
|
||||
#endif
|
||||
|
||||
exit(G.is_break == true);
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
void WM_script_tag_reload(void)
|
||||
|
@ -574,7 +574,7 @@ int main(int argc,
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
if (G.background) {
|
||||
/* Using window-manager API in background-mode is a bit odd, but works fine. */
|
||||
WM_exit(C);
|
||||
WM_exit(C, G.is_break ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
else {
|
||||
/* Shows the splash as needed. */
|
||||
|
@ -2271,9 +2271,7 @@ static bool handle_load_file(bContext *C, const char *filepath_arg, const bool l
|
||||
|
||||
if (error_msg) {
|
||||
fprintf(stderr, "Error: %s, exiting! %s\n", error_msg, filepath);
|
||||
|
||||
G.is_break = true;
|
||||
WM_exit(C);
|
||||
WM_exit(C, EXIT_FAILURE);
|
||||
/* Unreachable, return for clarity. */
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user