diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-05 16:46:55 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-09 15:26:29 +0300 |
commit | 103d29e2b2c0053436d0cef649ee9c6a24b2cba8 (patch) | |
tree | 1dd9d7b2ca12df4fbc80f1efc6ffd81dec45a184 /source/blender/blenlib/intern/BLI_timer.c | |
parent | 423435bd2e44e2fc9ec0e984d25a2d2141c59454 (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.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_timer.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_timer.c | 26 |
1 files changed, 3 insertions, 23 deletions
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(); } |