Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/message_bus/intern/wm_message_bus.c
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (BLI_listbase_is_empty(&msg_key->values)) { | ||||
| BLI_remlink(&mbus->messages, msg_key); | BLI_remlink(&mbus->messages, msg_key); | ||||
| bool ok = BLI_gset_remove(mbus->messages_gset[msg->type], msg_key, info->gset.key_free_fn); | bool ok = BLI_gset_remove(mbus->messages_gset[msg->type], msg_key, info->gset.key_free_fn); | ||||
| BLI_assert(ok); | BLI_assert(ok); | ||||
| UNUSED_VARS_NDEBUG(ok); | UNUSED_VARS_NDEBUG(ok); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void WM_msg_dump(struct wmMsgBus *mbus, const char *info_str) | char *WM_msg_sprintN(struct wmMsgBus *mbus) | ||||
| { | { | ||||
| printf(">>>> %s\n", info_str); | DynStr *message = BLI_dynstr_new(); | ||||
| LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { | LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { | ||||
| const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key); | const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key); | ||||
| const wmMsgTypeInfo *info = &wm_msg_types[msg->type]; | const wmMsgTypeInfo *info = &wm_msg_types[msg->type]; | ||||
| info->repr(stdout, key); | char *info_repr = info->repr(key); | ||||
| BLI_dynstr_appendf(message, "%s", info_repr); | |||||
| MEM_freeN(info_repr); | |||||
| } | } | ||||
| printf("<<<< %s\n", info_str); | char *cstring = BLI_dynstr_get_cstring(message); | ||||
| BLI_dynstr_free(message); | |||||
| return cstring; | |||||
| } | } | ||||
| static CLG_LogRef WM_LOG_MSGBUS_HANDLE = {"wm.msgbus.handle"}; | |||||
| void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C) | void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C) | ||||
| { | { | ||||
| if (mbus->messages_tag_count == 0) { | if (mbus->messages_tag_count == 0) { | ||||
| // printf("msgbus: skipping\n"); | CLOG_VERBOSE(&WM_LOG_MSGBUS_HANDLE, 4, "skipping msbus=%p", mbus); | ||||
| return; | return; | ||||
| } | } | ||||
| if (false) { | CLOG_STR_VERBOSE_N(&WM_LOG_MSGBUS_HANDLE, 4, WM_msg_sprintN(mbus)); | ||||
| WM_msg_dump(mbus, __func__); | |||||
| } | |||||
| // uint a = 0, b = 0; | // uint a = 0, b = 0; | ||||
| LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { | LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) { | ||||
| LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) { | LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) { | ||||
| if (msg_lnk->params.tag) { | if (msg_lnk->params.tag) { | ||||
| msg_lnk->params.notify(C, key, &msg_lnk->params); | msg_lnk->params.notify(C, key, &msg_lnk->params); | ||||
| msg_lnk->params.tag = false; | msg_lnk->params.tag = false; | ||||
| mbus->messages_tag_count -= 1; | mbus->messages_tag_count -= 1; | ||||
| } | } | ||||
| // b++; | // b++; | ||||
| } | } | ||||
| // a++; | // a++; | ||||
| } | } | ||||
| BLI_assert(mbus->messages_tag_count == 0); | BLI_assert(mbus->messages_tag_count == 0); | ||||
| mbus->messages_tag_count = 0; | mbus->messages_tag_count = 0; | ||||
| // printf("msgbus: keys=%u values=%u\n", a, b); | // CLOG_STR_INFO(&WM_LOG_MSGBUS_HANDLE, 4, "msgbus: keys=%u values=%u", a, b); | ||||
| } | } | ||||
| /** | /** | ||||
| * \param msg_key_test: Needs following #wmMsgSubscribeKey fields filled in: | * \param msg_key_test: Needs following #wmMsgSubscribeKey fields filled in: | ||||
| * - msg.params | * - msg.params | ||||
| * - msg.head.type | * - msg.head.type | ||||
| * - msg.head.id | * - msg.head.id | ||||
| * .. other values should be zeroed. | * .. other values should be zeroed. | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||