Fix T96888: data transfer operator crash in certain situation

The operator could crash in case the context "object" was overridden
from python, but the "active_object" wasnt (and the active object was
not a mesh).

Reason for the crash is a mismatch in the operators poll function
`data_transfer_poll` vs. `dt_layers_select_src_itemf` -- in the former,
the overriden "object" was respected (and if this was a mesh, the poll
was permissive), in the later it wasnt and only the "active_object" was
used (if this was not a mesh, a crash would happen trying to get an
evaluated mesh).

Now rectify how the object which is used is being fetched -> use
`ED_object_active_context` everywhere (see also rBe560bbe1d584).

Maniphest Tasks: T96888

Differential Revision: https://developer.blender.org/D14552
This commit is contained in:
Philipp Oeser 2022-04-05 09:49:55 +02:00
parent 384a02a214
commit 1d18c0682f
Notes: blender-bot 2023-02-14 06:00:44 +01:00
Referenced by issue #96888, Crash during lattice modifier evaluation during data transfer operator call with python
1 changed files with 1 additions and 1 deletions

View File

@ -137,7 +137,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
RNA_enum_items_add_value(
&item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
Object *ob_src = CTX_data_active_object(C);
Object *ob_src = ED_object_active_context(C);
if (ob_src == NULL) {
RNA_enum_item_end(&item, &totitem);
*r_free = true;