diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-25 12:34:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-25 12:43:53 +0400 |
commit | 1eb13519768f5735c9931fec0da07d92155796f1 (patch) | |
tree | 8f729eb436f370856d125ca580b3c55fe1bd4a6d /source/blender | |
parent | 258e30f2c7d2926ba5b206322ceb6876747d354d (diff) |
Fix T38924: wm.link_append() could fail to append
When the library path was changed by BLI_cleanup_path
appending would fail.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6ca8405dc7d..a291cffb89d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2423,6 +2423,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Main *mainl = NULL; BlendHandle *bh; + Library *lib; PropertyRNA *prop; char name[FILE_MAX], dir[FILE_MAX], libname[FILE_MAX], group[BLO_GROUP_MAX]; int idcode, totfiles = 0; @@ -2497,6 +2498,9 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* here appending/linking starts */ mainl = BLO_library_append_begin(bmain, &bh, libname); + lib = mainl->curlib; + BLI_assert(lib); + if (totfiles == 0) { BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); } @@ -2516,9 +2520,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* append, rather than linking */ if ((flag & FILE_LINK) == 0) { - Library *lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); - if (lib) BKE_library_make_local(bmain, lib, true); - else BLI_assert(!"cant find name of just added library!"); + BLI_assert(BLI_findindex(&bmain->library, lib) != -1); + BKE_library_make_local(bmain, lib, true); } /* important we unset, otherwise these object wont |