From 5066173fbfb1dfe6c4a122df730b5ab11ae3f4a0 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 6 Aug 2025 18:23:11 +0200 Subject: [PATCH] Fix #143110: Custom keymaps missing versioning for unified settings Introduced in 4434a30d4042594ee2fbb95f4b9c46da38ca950a The above commit changed many of the `wm.radial_control` default keybinds used in various paint modes to support accessing the "unified" properties on a per-mode basis. While the base Blender keymap and the industry compatible keymap were updated, this change was not applied to custom keymaps, leading to confusing behavior for the users. Pull Request: https://projects.blender.org/blender/blender/pulls/143872 --- scripts/modules/bl_keymap_utils/versioning.py | 70 +++++++++++++++++++ .../blender/blenkernel/BKE_blender_version.h | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/scripts/modules/bl_keymap_utils/versioning.py b/scripts/modules/bl_keymap_utils/versioning.py index 23c753f81ec..e178d46136a 100644 --- a/scripts/modules/bl_keymap_utils/versioning.py +++ b/scripts/modules/bl_keymap_utils/versioning.py @@ -15,6 +15,7 @@ __all__ = ( def keyconfig_update(keyconfig_data, keyconfig_version): + import re from bpy.app import version_file as blender_version if keyconfig_version >= blender_version: return keyconfig_data @@ -208,4 +209,73 @@ def keyconfig_update(keyconfig_data, keyconfig_version): rename_keymap({"Sequencer Tool: Rotate": "Preview Tool: Rotate"}) rename_keymap({"Sequencer Tool: Scale": "Preview Tool: Scale"}) + if keyconfig_version < (5, 0, 53): + if not has_copy: + keyconfig_data = copy.deepcopy(keyconfig_data) + has_copy = True + + # The `unified_paint_setting` struct was moved from `tool_settings` to be a sub-property of a given individual + # paint type. + # + # The following conversion maps from the old values of + # `tool_settings.unified_paint_settings.` + # to + # `tool_settings..unified_paint_settings.` + # where is retrieved from the `data_path_primary` property + # + # Example: + # `tool_settings.unified_paint_settings.size` + # and + # `tool_settings.unified_paint_settings.use_unified_size` + # for an operator with + # `tool_settings.sculpt.brush.size` + # become + # `tool_settings.sculpt.unified_paint_settings.size` + # and + # `tool_settings.sculpt.unified_paint_settings.use_unified_size` + + # Match paths of the form 'tool_settings..brush.' + re_toolsetting_brush = re.compile(r"^(tool_settings)\.([a-z_]+)\.(brush)\.(.*)") + + for _km_name, _km_parms, km_items_data in keyconfig_data: + for (item_op, _item_event, item_prop) in km_items_data["items"]: + if item_op == "wm.radial_control": + updated_path_elements = [] + secondary_path_index = -1 + secondary_path_identifier = "" + toggle_path_index = -1 + toggle_path_identifier = "" + + for prop_idx, (prop_id, prop_path) in enumerate(item_prop["properties"]): + if prop_id == "data_path_primary": + if re_toolsetting_brush.fullmatch(prop_path): + # Example: + # 'tool_settings.sculpt.brush.size' + # results in + # ['tool_settings', 'sculpt', 'unified_paint_settings'] + updated_path_elements = prop_path.split(".")[0:2] + updated_path_elements.append("unified_paint_settings") + elif prop_id == "data_path_secondary": + if prop_path.startswith("tool_settings.unified_paint_settings."): + # Example: + # 'tool_settings.unified_paint_settings.size' + # results in + # 'size' + secondary_path_index = prop_idx + secondary_path_identifier = prop_path.split(".", 2)[-1] + elif prop_id == "use_secondary": + if prop_path.startswith("tool_settings.unified_paint_settings."): + # Example: + # 'tool_settings.unified_paint_settings.use_unified_size' + # results in + # 'use_unified_size' + toggle_path_index = prop_idx + toggle_path_identifier = prop_path.split(".", 2)[-1] + + if updated_path_elements and secondary_path_index != -1 and toggle_path_index != -1: + item_prop["properties"][secondary_path_index] = ( + "data_path_secondary", ".".join((*updated_path_elements, secondary_path_identifier))) + item_prop["properties"][toggle_path_index] = ( + "use_secondary", ".".join((*updated_path_elements, toggle_path_identifier))) + return keyconfig_data diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index a57a46a758a..96d4f3749a5 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 52 +#define BLENDER_FILE_SUBVERSION 53 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to