Fix/workaround MSVC compile error with messag-bus

Some of the message-bus macros are not safe to use in C++. This has come
up before, but no good solution was found. Now @LazyDodo, @HooglyBoogly
and I concluded this is the best duct tape "solution" for the moment.
The message-bus API should address this.
This commit is contained in:
Julian Eisel 2022-01-13 20:40:52 +01:00
parent 1c4a1c13e0
commit 800fc17367
Notes: blender-bot 2023-02-14 10:43:47 +01:00
Referenced by commit 9b298cf3db, RNA: Generate property declerations header, solving msg-bus C++ incompatibility
Referenced by issue #96999, Mesh.calc_normals() after Mesh.transform() does not recalculate normals
5 changed files with 23 additions and 0 deletions

View File

@ -385,6 +385,8 @@ void outliner_collection_delete(
BLI_gset_free(data.collections_to_edit, nullptr);
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static int collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -408,6 +410,7 @@ static int collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
}
void OUTLINER_OT_collection_hierarchy_delete(wmOperatorType *ot)
{

View File

@ -668,6 +668,8 @@ static void scenes__collection_set_flag_recursive_fn(bContext *C, void *poin, vo
outliner_collection_set_flag_recursive_fn(C, nullptr, collection, propname);
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static void namebutton_fn(bContext *C, void *tsep, char *oldname)
{
Main *bmain = CTX_data_main(C);
@ -865,6 +867,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname)
tselem->flag &= ~TSE_TEXTBUT;
}
}
}
typedef struct RestrictProperties {
bool initialized;

View File

@ -1686,6 +1686,8 @@ static TreeTraversalAction outliner_find_objects_to_delete(TreeElement *te, void
return TRAVERSE_CONTINUE;
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static int outliner_delete_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
@ -1745,6 +1747,7 @@ static int outliner_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
}
void OUTLINER_OT_delete(wmOperatorType *ot)
{

View File

@ -262,6 +262,8 @@ static void outliner_main_region_listener(const wmRegionListenerParams *params)
}
}
/* FIXME: See comment above #WM_msg_publish_rna_prop(). */
extern "C" {
static void outliner_main_region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
struct wmMsgBus *mbus = params->message_bus;
@ -278,6 +280,7 @@ static void outliner_main_region_message_subscribe(const wmRegionMessageSubscrib
WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
}
}
}
/* ************************ header outliner area region *********************** */

View File

@ -244,6 +244,17 @@ void WM_msg_subscribe_ID(struct wmMsgBus *mbus,
const char *id_repr);
void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
/* FIXME
*
* For C++ code, some of the following macros need to be called in functions wrapped in
* `extern "C"` blocks. That is, the ones doing `extern PropertyRNA` declarations (trips up the
* MSVC linker).
* Although this shouldn't cause problems normally, if it does, the bits calling the macros can be
* moved to a separate function wrapped in `extern "C"`.
*
* Obviously this should be fixed properly (by not relying on inline `extern` declarations).
*/
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_) \
{ \
wmMsgParams_RNA msg_key_params_ = {{0}}; \