code cleanup: group python reset functions in BPY_python_reset()

This commit is contained in:
Campbell Barton
2013-06-09 23:31:53 +00:00
parent e70476db4b
commit e7a487d1e9
5 changed files with 12 additions and 13 deletions

View File

@@ -63,6 +63,7 @@ int BPY_is_pyconstraint(struct Text *text);
void BPY_python_start(int argc, const char **argv); void BPY_python_start(int argc, const char **argv);
void BPY_python_end(void); void BPY_python_end(void);
void BPY_python_reset(struct bContext *C);
/* 2.5 UI Scripts */ /* 2.5 UI Scripts */
int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports); int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);

View File

@@ -396,6 +396,13 @@ void BPY_python_end(void)
} }
void BPY_python_reset(bContext *C)
{
BPY_driver_reset();
BPY_app_handlers_reset(false);
BPY_modules_load_user(C);
}
static void python_script_error_jump_text(struct Text *text) static void python_script_error_jump_text(struct Text *text)
{ {
int lineno; int lineno;

View File

@@ -437,9 +437,7 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
/* run any texts that were loaded in and flagged as modules */ /* run any texts that were loaded in and flagged as modules */
BPY_driver_reset(); BPY_python_reset(C);
BPY_app_handlers_reset(FALSE);
BPY_modules_load_user(C);
#endif #endif
/* important to do before NULL'ing the context */ /* important to do before NULL'ing the context */
@@ -590,9 +588,7 @@ int wm_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
/* sync addons, these may have changed from the defaults */ /* sync addons, these may have changed from the defaults */
BPY_string_exec(C, "__import__('addon_utils').reset_all()"); BPY_string_exec(C, "__import__('addon_utils').reset_all()");
BPY_driver_reset(); BPY_python_reset(C);
BPY_app_handlers_reset(FALSE);
BPY_modules_load_user(C);
} }
#endif #endif

View File

@@ -174,10 +174,7 @@ void WM_init(bContext *C, int argc, const char **argv)
BPY_context_set(C); /* necessary evil */ BPY_context_set(C); /* necessary evil */
BPY_python_start(argc, argv); BPY_python_start(argc, argv);
BPY_driver_reset(); BPY_python_reset(C);
BPY_app_handlers_reset(FALSE); /* causes addon callbacks to be freed [#28068],
* but this is actually what we want. */
BPY_modules_load_user(C);
#else #else
(void)argc; /* unused */ (void)argc; /* unused */
(void)argv; /* unused */ (void)argv; /* unused */

View File

@@ -1250,9 +1250,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
/* WM_file_read() runs normally but since we're in background mode do here */ /* WM_file_read() runs normally but since we're in background mode do here */
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
/* run any texts that were loaded in and flagged as modules */ /* run any texts that were loaded in and flagged as modules */
BPY_driver_reset(); BPY_python_reset(C);
BPY_app_handlers_reset(FALSE);
BPY_modules_load_user(C);
#endif #endif
/* happens for the UI on file reading too (huh? (ton))*/ /* happens for the UI on file reading too (huh? (ton))*/