Fix T98225: file saved with an object in sculptmode that is disabled in viewports crashes on reload

Issue revealed by rB90e12e823ff0. Hidden objects may not be fully
evaluated by the despgraph, do not attempt to restore edit/sculpt/etc.
modes for those.

Should also be backported to 2.93 LTS release.
This commit is contained in:
Bastien Montagne 2022-05-18 17:19:15 +02:00
parent c56103356f
commit 14a893f20e
Notes: blender-bot 2023-02-14 09:36:46 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #98225, Regression: file saved with an object in sculptmode that is disabled in viewports crashes on reload
1 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,7 @@
#include "BKE_collection.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
@ -137,8 +138,12 @@ void ED_editors_init(bContext *C)
ED_object_posemode_enter_ex(bmain, ob);
}
/* Other edit/paint/etc. modes are only settable for objects in active scene currently. */
if (!BKE_collection_has_object_recursive(scene->master_collection, ob)) {
/* Other edit/paint/etc. modes are only settable for objects visible in active scene currently.
* Otherwise, they (and their obdata) may not be (fully) evaluated, which is mandatory for some
* modes like Sculpt.
* Ref. T98225. */
if (!BKE_collection_has_object_recursive(scene->master_collection, ob) ||
!BKE_scene_has_object(scene, ob) || (ob->visibility_flag & OB_HIDE_VIEWPORT) != 0) {
continue;
}