Fix T71405: Trying to Ctrl-C on many buttons crashes Blender

Usually Ctrl+C copies the operator name to the clipboard
["bpy.ops.material.new()", "bpy.ops.object.material_slot_remove()"]
Crash happens for all buttons of UI_BTYPE_BUT without associated
operator [some are defined with callbacks only, often these are created
with e.g uiDefIconBut (instead of e.g. uiDefIconButO)]

Other examples that crash with Ctrl+C:
- animation decorators next to animatable properties
- button to show a modifier texture in the texture tab
- ...

2.79 survived here (result in the clipboard was just not changed hitting
Ctrl+C on these buttons), this is what happens with this patch as well.

Maniphest Tasks: T71405

Differential Revision: https://developer.blender.org/D6208
This commit is contained in:
Philipp Oeser
2019-11-07 17:53:05 +01:00
parent e8cd2269b4
commit 3b66d2ed21

View File

@@ -2528,6 +2528,9 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
break;
case UI_BTYPE_BUT:
if (!but->optype) {
break;
}
ui_but_copy_operator(C, but, buf, buf_max_len);
is_buf_set = true;
break;