diff --git a/scripts/startup/bl_operators/copy_global_transform.py b/scripts/startup/bl_operators/copy_global_transform.py index 867695f5d9c..3260cd9ebfc 100644 --- a/scripts/startup/bl_operators/copy_global_transform.py +++ b/scripts/startup/bl_operators/copy_global_transform.py @@ -267,13 +267,28 @@ class OBJECT_OT_paste_transform(Operator): if not context.active_pose_bone and not context.active_object: cls.poll_message_set("Select an object or pose bone") return False - - clipboard = context.window_manager.clipboard.strip() - if not (clipboard.startswith("Matrix(") or clipboard.startswith(" Matrix | None: + if value.startswith("Matrix"): + return cls.parse_matrix(value) + if value.startswith(" Matrix | None: + import ast + try: + return Matrix(ast.literal_eval(value[6:])) + except Exception: + # ast.literal_eval() can raise a slew of exceptions, all of + # which means that it's not a matrix on the clipboard. + return None + @staticmethod def parse_print_m4(value: str) -> Optional[Matrix]: """Parse output from Blender's print_m4() function. @@ -285,7 +300,11 @@ class OBJECT_OT_paste_transform(Operator): if len(lines) != 4: return None - floats = tuple(tuple(float(item) for item in line.split()) for line in lines) + try: + floats = tuple(tuple(float(item) for item in line.split()) for line in lines) + except ValueError: + # Apprently not the expected format. + return None return Matrix(floats) @staticmethod @@ -296,22 +315,19 @@ class OBJECT_OT_paste_transform(Operator): if len(lines) != 4: return None - floats = tuple(tuple(float(item.strip()) for item in line.strip()[1:-1].split(',')) for line in lines) + try: + floats = tuple(tuple(float(item.strip()) for item in line.strip()[1:-1].split(',')) for line in lines) + except ValueError: + # Apprently not the expected format. + return None return Matrix(floats) def execute(self, context: Context) -> set[str]: - import ast - clipboard = context.window_manager.clipboard.strip() - if clipboard.startswith("Matrix"): - mat = Matrix(ast.literal_eval(clipboard[6:])) - elif clipboard.startswith("is_group()) { return OPERATOR_PASS_THROUGH; } + if (node->is_custom_group()) { + return OPERATOR_PASS_THROUGH; + } bNodeTree *group = id_cast(node->id); if (!group || ID_MISSING(group)) { return OPERATOR_PASS_THROUGH; diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index 703f4785168..bb6d803d05a 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -437,12 +437,12 @@ static bool ntree_shader_implicit_closure_cast(bNodeTree *ntree) } else if ((link->fromsock->type == SOCK_SHADER) && (link->tosock->type != SOCK_SHADER)) { blender::bke::node_remove_link(ntree, *link); - BKE_ntree_update_after_single_tree_change(*G.main, *ntree); + BKE_ntree_update_without_main(*ntree); modified = true; } } if (modified) { - BKE_ntree_update_after_single_tree_change(*G.main, *ntree); + BKE_ntree_update_without_main(*ntree); } return true; } @@ -736,7 +736,7 @@ static void ntree_shader_weight_tree_invert(bNodeTree *ntree, bNode *output_node *output_node, *thickness_output); } - BKE_ntree_update_after_single_tree_change(*G.main, *ntree); + BKE_ntree_update_without_main(*ntree); } static bool closure_node_filter(const bNode *node) @@ -788,7 +788,7 @@ static void ntree_shader_shader_to_rgba_branches(bNodeTree *ntree) continue; } ntree_shader_copy_branch(ntree, shader_to_rgba, closure_node_filter); - BKE_ntree_update_after_single_tree_change(*G.main, *ntree); + BKE_ntree_update_without_main(*ntree); ntree_shader_weight_tree_invert(ntree, shader_to_rgba); } @@ -981,7 +981,7 @@ static void ntree_shader_pruned_unused(bNodeTree *ntree, bNode *output_node) } if (changed) { - BKE_ntree_update_after_single_tree_change(*G.main, *ntree); + BKE_ntree_update_without_main(*ntree); } }