Fix T95706: Material asset not applied if appended and then linked

8f79fa9c67 was an attempt to fix this already, but it didn't quite
work. Problem was that the tooltip was messing with the drop-box and
operator properties, setting the name property for its own internal
logic. This name property would then be used rather than the session
UUID to query the material, which gave the wrong material (linking can
result in multiple IDs of the same type with the same name). A followup
commit will further sanitize this.
This commit is contained in:
Julian Eisel 2022-05-24 15:13:20 +02:00
parent 463077a3d5
commit bc3dbf109c
Notes: blender-bot 2023-02-14 01:35:49 +01:00
Referenced by commit cd412b4454, Drag & drop: Invert priority of name and session UUID in ID lookups
Referenced by issue #98365, Blender 3.2.0 Beta crashes on startup
Referenced by issue #95706, Asset Browser - Material is not applied if it is appended and then linked
3 changed files with 4 additions and 10 deletions

View File

@ -234,7 +234,7 @@ struct Base *ED_object_add_duplicate(struct Main *bmain,
void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr);
char *ED_object_ot_drop_named_material_tooltip(struct bContext *C,
struct PointerRNA *properties,
const char *name,
const int mval[2]);
/* bitflags for enter/exit editmode */

View File

@ -2594,9 +2594,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
/** \name Drop Named Material on Object Operator
* \{ */
char *ED_object_ot_drop_named_material_tooltip(bContext *C,
PointerRNA *properties,
const int mval[2])
char *ED_object_ot_drop_named_material_tooltip(bContext *C, const char *name, const int mval[2])
{
int mat_slot = 0;
Object *ob = ED_view3d_give_material_slot_under_cursor(C, mval, &mat_slot);
@ -2605,9 +2603,6 @@ char *ED_object_ot_drop_named_material_tooltip(bContext *C,
}
mat_slot = max_ii(mat_slot, 1);
char name[MAX_ID_NAME - 2];
RNA_string_get(properties, "name", name);
Material *prev_mat = BKE_object_material_get(ob, mat_slot);
char *result;

View File

@ -590,16 +590,15 @@ static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event
static char *view3d_mat_drop_tooltip(bContext *C,
wmDrag *drag,
const int xy[2],
struct wmDropBox *drop)
wmDropBox *UNUSED(drop))
{
const char *name = WM_drag_get_item_name(drag);
ARegion *region = CTX_wm_region(C);
RNA_string_set(drop->ptr, "name", name);
int mval[2] = {
xy[0] - region->winrct.xmin,
xy[1] - region->winrct.ymin,
};
return ED_object_ot_drop_named_material_tooltip(C, drop->ptr, mval);
return ED_object_ot_drop_named_material_tooltip(C, name, mval);
}
static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)