[Bf-blender-cvs] [f642aaf12fb] blender-v2.82-release: Fix T54270: Reset last_hit and last_location when reading the file

Pablo Dobarro noreply at git.blender.org
Mon Mar 9 20:56:34 CET 2020


Commit: f642aaf12fbb3701dd36178cd168ca9e74339c1c
Author: Pablo Dobarro
Date:   Wed Feb 19 19:07:16 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rBf642aaf12fbb3701dd36178cd168ca9e74339c1c

Fix T54270: Reset last_hit and last_location when reading the file

It does not make sense to read those values when loading a file and they can crash the cursor if they contain invalid coordinates.

Reviewed By: brecht

Maniphest Tasks: T54270

Differential Revision: https://developer.blender.org/D6754

===================================================================

M	source/blender/blenloader/intern/readfile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c39ecd90e01..7bb07359e88 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6891,6 +6891,13 @@ static void direct_link_scene(FileData *fd, Scene *sce)
 
   sce->toolsettings = newdataadr(fd, sce->toolsettings);
   if (sce->toolsettings) {
+
+    /* Reset last_location and last_hit, so they are not remembered across sessions. In some files
+     * these are also NaN, which could lead to crashes in painting. */
+    struct UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
+    zero_v3(ups->last_location);
+    ups->last_hit = 0;
+
     direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->sculpt);
     direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->vpaint);
     direct_link_paint_helper(fd, sce, (Paint **)&sce->toolsettings->wpaint);



More information about the Bf-blender-cvs mailing list