From 623bf30e4cfad2d2779685f42ff2921d9d39df10 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 1 Oct 2025 19:21:00 +0200 Subject: [PATCH] Fix #132016: UV Sculpt crash with bad tool data For a period of time during 4.2~4.3, the `UvSculpt` settings could have been in an invalid state. This commit reapplies the same versioning to prevent odd behavior and removes the old versioning code. Pull Request: https://projects.blender.org/blender/blender/pulls/147075 --- source/blender/blenkernel/BKE_blender_version.h | 2 +- .../blender/blenloader/intern/versioning_420.cc | 12 ------------ .../blender/blenloader/intern/versioning_500.cc | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index e4e6999425b..11d16c92eaf 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 97 +#define BLENDER_FILE_SUBVERSION 98 /* 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 diff --git a/source/blender/blenloader/intern/versioning_420.cc b/source/blender/blenloader/intern/versioning_420.cc index 94d9d88e1aa..f2c2dfaca26 100644 --- a/source/blender/blenloader/intern/versioning_420.cc +++ b/source/blender/blenloader/intern/versioning_420.cc @@ -964,18 +964,6 @@ void blo_do_versions_420(FileData *fd, Library * /*lib*/, Main *bmain) } } - if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 23)) { - LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { - ToolSettings *ts = scene->toolsettings; - if (!ts->uvsculpt.curve_distance_falloff) { - ts->uvsculpt.size = 50; - ts->uvsculpt.strength = 1.0f; - ts->uvsculpt.curve_distance_falloff_preset = BRUSH_CURVE_SMOOTH; - ts->uvsculpt.curve_distance_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - } - } - } - if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 24)) { if (!DNA_struct_member_exists(fd->filesdna, "Material", "char", "thickness_mode")) { LISTBASE_FOREACH (Material *, material, &bmain->materials) { diff --git a/source/blender/blenloader/intern/versioning_500.cc b/source/blender/blenloader/intern/versioning_500.cc index 1022feef35d..19add376882 100644 --- a/source/blender/blenloader/intern/versioning_500.cc +++ b/source/blender/blenloader/intern/versioning_500.cc @@ -3756,6 +3756,22 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain) FOREACH_NODETREE_END; } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 98)) { + /* For a brief period of time, these values were not properly versioned, so it is possible for + * files to be in an odd state. This versioning was formerly run in 4.2 subversion 23. */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + UvSculpt &uvsculpt = scene->toolsettings->uvsculpt; + if (uvsculpt.size == 0 || uvsculpt.curve_distance_falloff == nullptr) { + uvsculpt.size = 100; + uvsculpt.strength = 1.0f; + uvsculpt.curve_distance_falloff_preset = BRUSH_CURVE_SMOOTH; + if (uvsculpt.curve_distance_falloff == nullptr) { + uvsculpt.curve_distance_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + } + } + } + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.