Fix #98923 : Remove the ability to offset a linked collection asset not instantiated #104958

Open
Colin Marmond wants to merge 2 commits from Kdaf/blender:fix-98923-collection-asset-instance-offset_ into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 5 additions and 3 deletions
Showing only changes of commit 875924d74b - Show all commits

View File

@ -1859,16 +1859,18 @@ static int collection_drop_exec(bContext *C, wmOperator *op)
/* Disable location and rotation controls for the user when the collection
* is linked and not instantiated */
static bool collection_drop_poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop)
static bool collection_drop_poll_property(const bContext *C,
wmOperator *op,
const PropertyRNA *prop)
{
if (RNA_boolean_get(op->ptr, "use_instance"))
Review
Style: Always use braces https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Braces
return true;
const char *prop_name = RNA_property_ui_name(prop);
Review

This shouldn't use the UI name but the internal identifier, see RNA_property_identifier(). UI names are supposed to be changeable without compatibility concerns, plus they are translated. For example this code will break for languages that have "Rotation" or "Location" translated.

This shouldn't use the UI name but the internal identifier, see `RNA_property_identifier()`. UI names are supposed to be changeable without compatibility concerns, plus they are translated. For example this code will break for languages that have "Rotation" or "Location" translated.
if (STR_ELEM(prop_name, "Location", "Rotation")) {
Collection *collection = static_cast<Collection *>(
BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection")));
BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection")));
Review

This is not in sync with how collection_drop_exec() gets the collection, that first attempts to get the collection from the session UUID and the name, see collection_add_info_get_from_op().

This is not in sync with how `collection_drop_exec()` gets the collection, that first attempts to get the collection from the session UUID and the name, see `collection_add_info_get_from_op()`.
if (!ID_IS_LINKED(&collection->id))
Review

I'd omit the negation to make this more readable / less error-prone:

if (ID_IS_LINKED(&collection->id)) {
  return false;
}
return true;
I'd omit the negation to make this more readable / less error-prone: ``` if (ID_IS_LINKED(&collection->id)) { return false; } return true; ```
return true;
return false;