Fix #114892: crash opening old files with text objects
Exposed by16e4eeb9c0
. In (rare) occasions, a Curve's `CharInfo` can be NULL. This also crashed going into editmode on affected text objects in previous versions, however opening and rendering these files was still fine. In 4.0, opening those kind of files crashed. It is not entirely clear how this can happen (there are comments in code dating back to97df61a7e5
mentioning "old file", there might be other reasons, too), still, avoiding the crash on file open seems like good practice. Pull Request: https://projects.blender.org/blender/blender/pulls/114916
This commit is contained in:
parent
d46d1bbe6a
commit
578b479998
|
@ -1863,10 +1863,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
const int curvetype = BKE_curve_type_get(curve);
|
||||
if (curvetype == OB_FONT) {
|
||||
CharInfo *info = curve->strinfo;
|
||||
for (int i = curve->len_char32 - 1; i >= 0; i--, info++) {
|
||||
if (info->mat_nr > 0) {
|
||||
/** CharInfo mat_nr used to start at 1, unlike mesh & nurbs, now zero-based. */
|
||||
info->mat_nr--;
|
||||
if (info != nullptr) {
|
||||
for (int i = curve->len_char32 - 1; i >= 0; i--, info++) {
|
||||
if (info->mat_nr > 0) {
|
||||
/** CharInfo mat_nr used to start at 1, unlike mesh & nurbs, now zero-based. */
|
||||
info->mat_nr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue