Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-09-05 16:46:55 +0300
committerYimingWu <xp8110@outlook.com>2019-09-12 04:13:03 +0300
commit92071691752e3098ef91fe1ceac060f27bc744b8 (patch)
tree90766061a1ceeef4309ada1c98a487fa1a814b7b
parentfb4ae7c229c6d3d7707e5657f658dab98e2f32a3 (diff)
Timer: Use explicit re-initialization on file load
Before this the timer API was relying on using a callback API to do initialization when new file is loaded. This isn't how rest of Blender works and it gets in a way because callbacks API is to be move to the BKE level. Use explicit call to timer API from where the file is loaded.
-rw-r--r--source/blender/blenlib/BLI_timer.h4
-rw-r--r--source/blender/blenlib/intern/BLI_timer.c26
-rw-r--r--source/blender/windowmanager/intern/wm_files.c3
3 files changed, 10 insertions, 23 deletions
diff --git a/source/blender/blenlib/BLI_timer.h b/source/blender/blenlib/BLI_timer.h
index dc47aefa090..959ac4a2b2b 100644
--- a/source/blender/blenlib/BLI_timer.h
+++ b/source/blender/blenlib/BLI_timer.h
@@ -50,4 +50,8 @@ void BLI_timer_execute(void);
void BLI_timer_free(void);
+/* This function is to be called next to BLI_CB_EVT_LOAD_PRE, to make sure the module
+ * is properly configured for the new file. */
+void BLI_timer_on_file_load(void);
+
#endif /* __BLI_TIMER_H__ */
diff --git a/source/blender/blenlib/intern/BLI_timer.c b/source/blender/blenlib/intern/BLI_timer.c
index bf9fd1b57f8..7ff320083eb 100644
--- a/source/blender/blenlib/intern/BLI_timer.c
+++ b/source/blender/blenlib/intern/BLI_timer.c
@@ -23,7 +23,6 @@
#include "BLI_timer.h"
#include "BLI_listbase.h"
-#include "BLI_callbacks.h"
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
@@ -48,8 +47,6 @@ typedef struct TimerContainer {
static TimerContainer GlobalTimer = {{0}};
-static void ensure_callback_is_registered(void);
-
void BLI_timer_register(uintptr_t uuid,
BLI_timer_func func,
void *user_data,
@@ -57,8 +54,6 @@ void BLI_timer_register(uintptr_t uuid,
double first_interval,
bool persistent)
{
- ensure_callback_is_registered();
-
TimedFunction *timed_func = MEM_callocN(sizeof(TimedFunction), __func__);
timed_func->func = func;
timed_func->user_data_free = user_data_free;
@@ -156,11 +151,7 @@ void BLI_timer_free()
remove_tagged_functions();
}
-struct ID;
-struct Main;
-static void remove_non_persistent_functions(struct Main *UNUSED(_1),
- struct ID *UNUSED(_2),
- void *UNUSED(_3))
+static void remove_non_persistent_functions(void)
{
LISTBASE_FOREACH (TimedFunction *, timed_func, &GlobalTimer.funcs) {
if (!timed_func->persistent) {
@@ -169,18 +160,7 @@ static void remove_non_persistent_functions(struct Main *UNUSED(_1),
}
}
-static bCallbackFuncStore load_pre_callback = {
- NULL,
- NULL, /* next, prev */
- remove_non_persistent_functions, /* func */
- NULL, /* arg */
- 0, /* alloc */
-};
-
-static void ensure_callback_is_registered()
+void BLI_timer_on_file_load(void)
{
- if (!GlobalTimer.file_load_cb_registered) {
- BLI_callback_add(&load_pre_callback, BLI_CB_EVT_LOAD_PRE);
- GlobalTimer.file_load_cb_registered = true;
- }
+ remove_non_persistent_functions();
}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a2e7f7fe935..e70640d2f22 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -52,6 +52,7 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_utildefines.h"
+#include "BLI_timer.h"
#include "BLI_threads.h"
#include "BLI_callbacks.h"
#include "BLI_system.h"
@@ -609,6 +610,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
WM_cursor_wait(1);
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE);
+ BLI_timer_on_file_load();
UI_view2d_zoom_cache_reset();
@@ -806,6 +808,7 @@ void wm_homefile_read(bContext *C,
if (use_data) {
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE);
+ BLI_timer_on_file_load();
G.relbase_valid = 0;