diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-11-09 18:04:51 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-11-09 23:00:53 +0300 |
commit | cf959a879eb5ffbdfa573c5f3a00965e69d7a976 (patch) | |
tree | d25aba06e9040befb286119bb7f7e2fc8742df39 | |
parent | 92f059774d30faf73a695138456f57de49a9b5e4 (diff) |
Cleanup: readfile: get rid of USER_ONE, replaced by USER_REAL everywhere.
USER_ONE was only ensuring id->us was non-zero, while USER_REAL ensures
it is non-zero **and** >1 in case fake_user flag is set (which at least
ensures us unsetting fake_user won't leave id->us in invalid zero state).
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6c6af2d1fc6..9ebae184dd4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6348,20 +6348,14 @@ static void lib_link_screen(FileData *fd, Main *main) /* how to handle user count on pointer restore */ typedef enum ePointerUserMode { USER_IGNORE = 0, /* ignore user count */ - USER_ONE = 1, /* ensure at least one user (fake also counts) */ - USER_REAL = 2, /* ensure at least one real user (fake user ignored) */ + USER_REAL = 1, /* ensure at least one real user (fake user ignored) */ } ePointerUserMode; static bool restore_pointer(ID *id, ID *newid, ePointerUserMode user) { if (STREQ(newid->name + 2, id->name + 2)) { if (newid->lib == id->lib) { - if (user == USER_ONE) { - if (newid->us == 0) { - newid->us++; - } - } - else if (user == USER_REAL) { + if (user == USER_REAL) { id_us_ensure_real(newid); } return true; @@ -6375,7 +6369,6 @@ static bool restore_pointer(ID *id, ID *newid, ePointerUserMode user) * * user * - USER_IGNORE: no usercount change - * - USER_ONE: ensure a user * - USER_REAL: ensure a real user (even if a fake one is set) */ static void *restore_pointer_by_name(Main *mainp, ID *id, ePointerUserMode user) @@ -6401,7 +6394,7 @@ static void lib_link_seq_clipboard_pt_restore(ID *id, Main *newmain) if (id) { /* clipboard must ensure this */ BLI_assert(id->newid != NULL); - id->newid = restore_pointer_by_name(newmain, (ID *)id->newid, USER_ONE); + id->newid = restore_pointer_by_name(newmain, (ID *)id->newid, USER_REAL); } } static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt) @@ -6435,7 +6428,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc /* first windowmanager */ for (wm = newmain->wm.first; wm; wm = wm->id.next) { for (win= wm->windows.first; win; win= win->next) { - win->screen = restore_pointer_by_name(newmain, (ID *)win->screen, USER_ONE); + win->screen = restore_pointer_by_name(newmain, (ID *)win->screen, USER_REAL); if (win->screen == NULL) win->screen = curscreen; @@ -6448,7 +6441,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc for (sc = newmain->screen.first; sc; sc = sc->id.next) { Scene *oldscene = sc->scene; - sc->scene= restore_pointer_by_name(newmain, (ID *)sc->scene, USER_ONE); + sc->scene= restore_pointer_by_name(newmain, (ID *)sc->scene, USER_REAL); if (sc->scene == NULL) sc->scene = curscene; @@ -6467,10 +6460,10 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc if (v3d->scenelock) v3d->camera = NULL; /* always get from scene */ else - v3d->camera = restore_pointer_by_name(newmain, (ID *)v3d->camera, USER_ONE); + v3d->camera = restore_pointer_by_name(newmain, (ID *)v3d->camera, USER_REAL); if (v3d->camera == NULL) v3d->camera = sc->scene->camera; - v3d->ob_centre = restore_pointer_by_name(newmain, (ID *)v3d->ob_centre, USER_ONE); + v3d->ob_centre = restore_pointer_by_name(newmain, (ID *)v3d->ob_centre, USER_REAL); for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { if ((bgpic->ima = restore_pointer_by_name(newmain, (ID *)bgpic->ima, USER_IGNORE))) { @@ -6520,7 +6513,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc bDopeSheet *ads = sipo->ads; if (ads) { - ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, USER_ONE); + ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, USER_REAL); if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, USER_IGNORE); @@ -6550,8 +6543,8 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc else if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; - saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, USER_ONE); - saction->ads.source = restore_pointer_by_name(newmain, (ID *)saction->ads.source, USER_ONE); + saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, USER_REAL); + saction->ads.source = restore_pointer_by_name(newmain, (ID *)saction->ads.source, USER_REAL); if (saction->ads.filter_grp) saction->ads.filter_grp = restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, USER_IGNORE); @@ -6580,7 +6573,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so assume that here we're doing for undo only... */ - sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, USER_ONE); + sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, USER_REAL); sima->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sima->mask_info.mask, USER_REAL); } else if (sl->spacetype == SPACE_SEQ) { @@ -6589,14 +6582,14 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so assume that here we're doing for undo only... */ - sseq->gpd = restore_pointer_by_name(newmain, (ID *)sseq->gpd, USER_ONE); + sseq->gpd = restore_pointer_by_name(newmain, (ID *)sseq->gpd, USER_REAL); } else if (sl->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)sl; bDopeSheet *ads = snla->ads; if (ads) { - ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, USER_ONE); + ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, USER_REAL); if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, USER_IGNORE); @@ -6605,13 +6598,13 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc else if (sl->spacetype == SPACE_TEXT) { SpaceText *st = (SpaceText *)sl; - st->text = restore_pointer_by_name(newmain, (ID *)st->text, USER_ONE); + st->text = restore_pointer_by_name(newmain, (ID *)st->text, USER_REAL); if (st->text == NULL) st->text = newmain->text.first; } else if (sl->spacetype == SPACE_SCRIPT) { SpaceScript *scpt = (SpaceScript *)sl; - scpt->script = restore_pointer_by_name(newmain, (ID *)scpt->script, USER_ONE); + scpt->script = restore_pointer_by_name(newmain, (ID *)scpt->script, USER_REAL); /*sc->script = NULL; - 2.45 set to null, better re-run the script */ if (scpt->script) { @@ -6649,7 +6642,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc bNodeTree *ntree; /* node tree can be stored locally in id too, link this first */ - snode->id = restore_pointer_by_name(newmain, snode->id, USER_ONE); + snode->id = restore_pointer_by_name(newmain, snode->id, USER_REAL); snode->from = restore_pointer_by_name(newmain, snode->from, USER_IGNORE); ntree = nodetree_from_id(snode->id); @@ -6698,7 +6691,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc else if (sl->spacetype == SPACE_LOGIC) { SpaceLogic *slogic = (SpaceLogic *)sl; - slogic->gpd = restore_pointer_by_name(newmain, (ID *)slogic->gpd, USER_ONE); + slogic->gpd = restore_pointer_by_name(newmain, (ID *)slogic->gpd, USER_REAL); } } } |