add event_clear_custom_name

This commit is contained in:
lixianjing 2024-10-18 18:16:11 +08:00
parent 6ba483fa12
commit 6593f0056e
4 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2024/10/18
* 程序结束时自动释放事件注册名称(感谢兆坤提供补丁)
2024/10/17
* 增加给给事件注册名称的功能(感谢兆坤提供补丁)
* 完善fscript错误提示(感谢兆坤提供补丁)

View File

@ -36,6 +36,7 @@
#include "base/window_manager.h"
#include "base/widget_factory.h"
#include "base/assets_manager.h"
#include "base/events.h"
#include "fscript_ext/fscript_ext.h"
#ifdef FSCRIPT_WITH_WIDGET
#include "fscript_ext/fscript_widget.h"
@ -432,6 +433,9 @@ ret_t tk_deinit_internal(void) {
#ifndef WITHOUT_FSCRIPT
fscript_global_deinit();
#endif
event_clear_custom_name();
tk_semaphore_destroy(s_clear_cache_semaphore);
#ifdef WITH_SOCKET

View File

@ -45,17 +45,16 @@ ret_t event_unregister_custom_name(const char* name) {
if (s_custom_event_names != NULL) {
ret = tk_object_remove_prop(s_custom_event_names, name);
if (RET_OK == ret) {
int32_t size = tk_object_get_prop_int(s_custom_event_names, TK_OBJECT_PROP_SIZE, 0);
if (0 == size) {
TK_OBJECT_UNREF(s_custom_event_names);
}
}
}
return ret;
}
ret_t event_clear_custom_name(void) {
TK_OBJECT_UNREF(s_custom_event_names);
return RET_OK;
}
static inline int32_t event_get_custom_name(const char* name) {
if (s_custom_event_names == NULL) {
return EVT_NONE;

View File

@ -1393,6 +1393,9 @@ ret_t event_register_custom_name(int32_t event_type, const char* name);
*/
ret_t event_unregister_custom_name(const char* name);
/* private */
ret_t event_clear_custom_name(void);
#define STR_ON_EVENT_PREFIX "on:"
#define STR_GLOBAL_EVENT_PREFIX "global"
#define STR_GLOBAL_VARS_CHANGED "global_vars_changed"