code cleanup: group python reset functions in BPY_python_reset()
authorCampbell Barton <ideasman42@gmail.com>
Sun, 9 Jun 2013 23:31:53 +0000 (23:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 9 Jun 2013 23:31:53 +0000 (23:31 +0000)
source/blender/python/BPY_extern.h
source/blender/python/intern/bpy_interface.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c
source/creator/creator.c

index 0f5be095e0fcd272fac1037d74311a5b6dc6eca2..e61b4847e2cb5f24113807f56bccbb4d783d09c4 100644 (file)
@@ -63,6 +63,7 @@ int BPY_is_pyconstraint(struct Text *text);
 
 void BPY_python_start(int argc, const char **argv);
 void BPY_python_end(void);
+void BPY_python_reset(struct bContext *C);
 
 /* 2.5 UI Scripts */
 int            BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);
index f71ea02a5100b46ae1ee5863bac4d378acfc1bec..75827ce8bbfe24d62c62d69fdf197331347d3ad3 100644 (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)
 {
        int lineno;
index 7a528e419959db0ab61aea8f99fa635173b455b4..c372e2d1ce62ce32eee9f54005bb2970917c2675 100644 (file)
@@ -437,9 +437,7 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
 
 #ifdef WITH_PYTHON
                /* run any texts that were loaded in and flagged as modules */
-               BPY_driver_reset();
-               BPY_app_handlers_reset(FALSE);
-               BPY_modules_load_user(C);
+               BPY_python_reset(C);
 #endif
 
                /* 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 */
                BPY_string_exec(C, "__import__('addon_utils').reset_all()");
 
-               BPY_driver_reset();
-               BPY_app_handlers_reset(FALSE);
-               BPY_modules_load_user(C);
+               BPY_python_reset(C);
        }
 #endif
 
index 31f2b412a7f0353cf7fa3a0e03e6960d0ad98163..8115779a7c64ad664a72c576b5ccae572e0a090f 100644 (file)
@@ -174,10 +174,7 @@ void WM_init(bContext *C, int argc, const char **argv)
        BPY_context_set(C); /* necessary evil */
        BPY_python_start(argc, argv);
 
-       BPY_driver_reset();
-       BPY_app_handlers_reset(FALSE); /* causes addon callbacks to be freed [#28068],
-                                       * but this is actually what we want. */
-       BPY_modules_load_user(C);
+       BPY_python_reset(C);
 #else
        (void)argc; /* unused */
        (void)argv; /* unused */
index fdd0169123273142c1ae8e7749a82322a7658991..1451a52569435582b5bb409e04b0d88c5ffa01d9 100644 (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 */
 #ifdef WITH_PYTHON
                /* run any texts that were loaded in and flagged as modules */
-               BPY_driver_reset();
-               BPY_app_handlers_reset(FALSE);
-               BPY_modules_load_user(C);
+               BPY_python_reset(C);
 #endif
 
                /* happens for the UI on file reading too (huh? (ton))*/