diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-12-04 19:03:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-12-04 19:05:15 +0300 |
commit | c370fffc9bd0900a30e04ac631641d43e0f217a5 (patch) | |
tree | 38eaad49dca1499ebb91c13759f4959dc4e27eca /source/blender/windowmanager | |
parent | d37d6b5a4d85a9bbace0e74f96e8eb6a5a4c056e (diff) |
Resolve MSVC C2229
Code works as expected, but MSVC disallows
Diffstat (limited to 'source/blender/windowmanager')
3 files changed, 22 insertions, 7 deletions
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c index 0e7486fa293..7183655b0de 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c @@ -95,9 +95,10 @@ void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner) } if (BLI_listbase_is_empty(&msg_key->values)) { - wmMsgTypeInfo *info = &wm_msg_types[msg_key->msg->type]; + const wmMsg *msg = wm_msg_subscribe_value_msg_cast(msg_key); + wmMsgTypeInfo *info = &wm_msg_types[msg->type]; BLI_remlink(&mbus->messages, msg_key); - bool ok = BLI_gset_remove(mbus->messages_gset[msg_key->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); UNUSED_VARS_NDEBUG(ok); } @@ -108,7 +109,8 @@ void WM_msg_dump(struct wmMsgBus *mbus, const char *info_str) { printf(">>>> %s\n", info_str); for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) { - const wmMsgTypeInfo *info = &wm_msg_types[key->msg->type]; + const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key); + const wmMsgTypeInfo *info = &wm_msg_types[msg->type]; info->repr(stdout, key); } printf("<<<< %s\n", info_str); @@ -157,11 +159,11 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key( const wmMsgSubscribeKey *msg_key_test, const wmMsgSubscribeValue *msg_val_params) { - const uint type = msg_key_test->msg->type; + const uint type = wm_msg_subscribe_value_msg_cast(msg_key_test)->type; const wmMsgTypeInfo *info = &wm_msg_types[type]; wmMsgSubscribeKey *key; - BLI_assert(msg_key_test->msg->id != NULL); + BLI_assert(wm_msg_subscribe_value_msg_cast(msg_key_test)->id != NULL); void **r_key; if (!BLI_gset_ensure_p_ex(mbus->messages_gset[type], msg_key_test, &r_key)) { diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h index 8d7b9d4ced2..db8b481a3c2 100644 --- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h +++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h @@ -38,4 +38,18 @@ struct wmMsgBus { void wm_msg_subscribe_value_free( struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValueLink *msg_lnk); +typedef struct wmMsgSubscribeKey_Generic { + wmMsgSubscribeKey head; + wmMsg msg; +} wmMsgSubscribeKey_Generic; + +BLI_INLINE const wmMsg *wm_msg_subscribe_value_msg_cast(const wmMsgSubscribeKey *key) +{ + return &((wmMsgSubscribeKey_Generic *)key)->msg; +} +BLI_INLINE wmMsg *wm_msg_subscribe_value_msg_cast_mut(wmMsgSubscribeKey *key) +{ + return &((wmMsgSubscribeKey_Generic *)key)->msg; +} + #endif /* __WM_MESSAGE_BUS_INTERN_H__ */ diff --git a/source/blender/windowmanager/message_bus/wm_message_bus.h b/source/blender/windowmanager/message_bus/wm_message_bus.h index fd158e2cd7f..53f283cacd2 100644 --- a/source/blender/windowmanager/message_bus/wm_message_bus.h +++ b/source/blender/windowmanager/message_bus/wm_message_bus.h @@ -80,9 +80,8 @@ typedef struct wmMsgSubscribeKey { /** Linked list for predicable ordering, otherwise we would depend on ghash bucketing. */ struct wmMsgSubscribeKey *next, *prev; ListBase values; - /* over-alloc, eg: wmMsgSubscribeKey_RNA */ - wmMsg msg[0]; + /* Last member will be 'wmMsg_*' */ } wmMsgSubscribeKey; /** One of many in #wmMsgSubscribeKey.values */ |