fix [#33580] Masking keyframes disappear from dope sheet when using undo.
This commit is contained in:
@@ -62,6 +62,7 @@ void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const shor
|
||||
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
|
||||
void id_lib_extern(struct ID *id);
|
||||
void BKE_library_filepath_set(struct Library *lib, const char *filepath);
|
||||
void id_us_ensure_real(struct ID *id);
|
||||
void id_us_plus(struct ID *id);
|
||||
void id_us_min(struct ID *id);
|
||||
|
||||
|
||||
@@ -152,6 +152,14 @@ void id_lib_extern(ID *id)
|
||||
}
|
||||
}
|
||||
|
||||
/* ensure we have a real user */
|
||||
void id_us_ensure_real(ID *id)
|
||||
{
|
||||
if (ID_REAL_USERS(id) <= 0) {
|
||||
id->us = MAX2(id->us, 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void id_us_plus(ID *id)
|
||||
{
|
||||
if (id) {
|
||||
|
||||
@@ -5414,7 +5414,14 @@ static void *restore_pointer_by_name(Main *mainp, ID *id, int user)
|
||||
for (; idn; idn = idn->next) {
|
||||
if (idn->name[2] == name[0] && strcmp(idn->name+2, name) == 0) {
|
||||
if (idn->lib == id->lib) {
|
||||
if (user && idn->us == 0) idn->us++;
|
||||
if (user == 1) {
|
||||
if (idn->us == 0) {
|
||||
idn->us++;
|
||||
}
|
||||
}
|
||||
else if (user == 2) {
|
||||
id_us_ensure_real(idn);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5580,7 +5587,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
|
||||
else if (sl->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->image = restore_pointer_by_name(newmain, (ID *)sima->image, 1);
|
||||
sima->image = restore_pointer_by_name(newmain, (ID *)sima->image, 2);
|
||||
|
||||
/* this will be freed, not worth attempting to find same scene,
|
||||
* since it gets initialized later */
|
||||
@@ -5596,7 +5603,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
|
||||
* so assume that here we're doing for undo only...
|
||||
*/
|
||||
sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, 1);
|
||||
sima->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sima->mask_info.mask, 1);
|
||||
sima->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sima->mask_info.mask, 2);
|
||||
}
|
||||
else if (sl->spacetype == SPACE_SEQ) {
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
@@ -5671,8 +5678,8 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
|
||||
else if (sl->spacetype == SPACE_CLIP) {
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
|
||||
sclip->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sclip->mask_info.mask, 1);
|
||||
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 2);
|
||||
sclip->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sclip->mask_info.mask, 2);
|
||||
|
||||
sclip->scopes.ok = 0;
|
||||
}
|
||||
|
||||
@@ -1236,7 +1236,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
case ANIMTYPE_MASKLAYER:
|
||||
{
|
||||
/* Grease Pencil layer */
|
||||
/* Mask layer */
|
||||
Mask *mask = (Mask *)ale->id;
|
||||
MaskLayer *masklay = (MaskLayer *)ale->data;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "BKE_movieclip.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_tracking.h"
|
||||
#include "BKE_library.h"
|
||||
|
||||
#include "DNA_mask_types.h"
|
||||
#include "DNA_object_types.h" /* SELECT */
|
||||
@@ -524,8 +525,7 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
|
||||
old_clip = sc->clip;
|
||||
sc->clip = clip;
|
||||
|
||||
if (sc->clip && sc->clip->id.us == 0)
|
||||
sc->clip->id.us = 1;
|
||||
id_us_ensure_real((ID *)sc->clip);
|
||||
|
||||
if (screen && sc->view == SC_VIEW_CLIP) {
|
||||
ScrArea *area;
|
||||
@@ -561,9 +561,7 @@ void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
|
||||
{
|
||||
sc->mask_info.mask = mask;
|
||||
|
||||
if (sc->mask_info.mask && sc->mask_info.mask->id.us == 0) {
|
||||
sc->mask_info.mask->id.us = 1;
|
||||
}
|
||||
id_us_ensure_real((ID *)sc->mask_info.mask);
|
||||
|
||||
if (C) {
|
||||
WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_tessmesh.h"
|
||||
#include "BKE_library.h"
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
@@ -78,8 +79,7 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
|
||||
if (sima->image)
|
||||
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
||||
|
||||
if (sima->image && ID_REAL_USERS(sima->image) <= 0)
|
||||
sima->image->id.us = max_ii(sima->image->id.us, 0) + 1;
|
||||
id_us_ensure_real((ID *)sima->image);
|
||||
|
||||
if (obedit)
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
|
||||
@@ -97,8 +97,7 @@ void ED_space_image_set_mask(bContext *C, SpaceImage *sima, Mask *mask)
|
||||
sima->mask_info.mask = mask;
|
||||
|
||||
/* weak, but same as image/space */
|
||||
if (sima->mask_info.mask && ID_REAL_USERS(sima->mask_info.mask) <= 0)
|
||||
sima->mask_info.mask->id.us = max_ii(sima->mask_info.mask->id.us, 0) + 1;
|
||||
id_us_ensure_real((ID *)sima->mask_info.mask);
|
||||
|
||||
if (C) {
|
||||
WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask);
|
||||
|
||||
Reference in New Issue
Block a user