Fix T94599: Assert on usercount when deleting image created via operator.

`IMAGE_OT_new` operator would not properly clear the by-default one user
generated by 'new id' code, in case it could not tie the image to
anything.
This commit is contained in:
Bastien Montagne 2022-01-04 10:03:31 +01:00
parent a2a02e3994
commit b2867d4365
Notes: blender-bot 2023-02-13 16:36:44 +01:00
Referenced by issue #94599, Crash Debug Build: Delete created image with Python.
1 changed files with 5 additions and 0 deletions

View File

@ -2595,6 +2595,11 @@ static int image_new_exec(bContext *C, wmOperator *op)
else if (sima) {
ED_space_image_set(bmain, sima, ima, false);
}
else {
/* #BKE_image_add_generated creates one user by default, remove it if image is not linked to
* anything. ref. T94599. */
id_us_min(&ima->id);
}
BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);