diff options
author | Julian Eisel <julian@blender.org> | 2022-05-24 17:47:48 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-24 18:08:02 +0300 |
commit | 7b778166db4048b5109146bc073ab85fa49261f4 (patch) | |
tree | 8d95e63e4c3fd655ccc322c1fd8cda49b79465ce /source/blender/windowmanager | |
parent | 25d216724bc195d25aaaf336ab1cd3e7c55d78bf (diff) |
Cleanup: Use new helpers for passing IDs from drag & drop to operators
There are now some generalized helpers for passing IDs from drag & drop
to operators via operator properties, mostly introduced in 917c096be6b9
and 8f79fa9c6780. These can be used in a bunch of places to reduce
duplicated code and explicitly share a common solution.
Side-effect: The "Name" property won't show up in the Adjust Last
Operation anymore, and its value won't be remembered over multiple
executions of the operator. Both were not at all useful from what I can
tell, and I doubt this was done intentionally.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 12cafbd7c64..1ed3174ee6f 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -789,6 +789,11 @@ struct ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(struct Mai PointerRNA *ptr, enum ID_Type type); /** + * Check if either the "session_uuid" or "name" property is set inside \a ptr. If this is the case + * the ID can be looked up by #WM_operator_properties_id_lookup_from_name_or_session_uuid(). + */ +bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr); +/** * Adds "name" and "session_uuid" properties so the caller can tell the operator which ID to act * on. See #WM_operator_properties_id_lookup_from_name_or_session_uuid(). Both properties will be * hidden in the UI and not be saved over consecutive operator calls. diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 96f711bb237..71c948dfbb9 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -262,6 +262,12 @@ ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, return NULL; } +bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr) +{ + return RNA_struct_property_is_set(ptr, "session_uuid") || + RNA_struct_property_is_set(ptr, "name"); +} + void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop) { PropertyRNA *prop; |