use generic path remapping when making all library data local, previously only image paths were getting corrected, now all paths will (scene image seq strips, pointcache etc)
This commit is contained in:
@@ -78,7 +78,7 @@ void rename_id(struct ID *id, const char *name);
|
|||||||
void name_uiprefix_id(char *name, struct ID *id);
|
void name_uiprefix_id(char *name, struct ID *id);
|
||||||
void test_idbutton(char *name);
|
void test_idbutton(char *name);
|
||||||
void text_idbutton(struct ID *id, char *text);
|
void text_idbutton(struct ID *id, char *text);
|
||||||
void all_local(struct Library *lib, int untagged_only);
|
void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only);
|
||||||
struct ID *find_id(const char *type, const char *name);
|
struct ID *find_id(const char *type, const char *name);
|
||||||
void clear_id_newpoins(void);
|
void clear_id_newpoins(void);
|
||||||
|
|
||||||
|
@@ -1277,16 +1277,6 @@ void clear_id_newpoins(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only for library fixes */
|
|
||||||
static void image_fix_relative_path(Image *ima)
|
|
||||||
{
|
|
||||||
if(ima->id.lib==NULL) return;
|
|
||||||
if(strncmp(ima->name, "//", 2)==0) {
|
|
||||||
BLI_path_abs(ima->name, ima->id.lib->filepath);
|
|
||||||
BLI_path_rel(ima->name, G.main->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
|
#define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
|
||||||
|
|
||||||
static void lib_indirect_test_id(ID *id, Library *lib)
|
static void lib_indirect_test_id(ID *id, Library *lib)
|
||||||
@@ -1361,14 +1351,15 @@ void tag_main(struct Main *mainvar, const short tag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if lib!=NULL, only all from lib local */
|
/* if lib!=NULL, only all from lib local
|
||||||
void all_local(Library *lib, int untagged_only)
|
* bmain is almost certainly G.main */
|
||||||
|
void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
|
||||||
{
|
{
|
||||||
ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
|
ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
|
||||||
ID *id, *idn;
|
ID *id, *idn;
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
a= set_listbasepointers(G.main, lbarray);
|
a= set_listbasepointers(bmain, lbarray);
|
||||||
while(a--) {
|
while(a--) {
|
||||||
id= lbarray[a]->first;
|
id= lbarray[a]->first;
|
||||||
|
|
||||||
@@ -1385,17 +1376,16 @@ void all_local(Library *lib, int untagged_only)
|
|||||||
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
|
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
|
||||||
{
|
{
|
||||||
if(lib==NULL || id->lib==lib) {
|
if(lib==NULL || id->lib==lib) {
|
||||||
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
|
|
||||||
|
|
||||||
if(id->lib) {
|
if(id->lib) {
|
||||||
/* relative file patch */
|
id_clear_lib_data(bmain, id); /* sets 'id->flag' */
|
||||||
if(GS(id->name)==ID_IM)
|
|
||||||
image_fix_relative_path((Image *)id);
|
/* why sort alphabetically here but not in
|
||||||
|
* id_clear_lib_data() ? - campbell */
|
||||||
id->lib= NULL;
|
|
||||||
new_id(lbarray[a], id, NULL); /* new_id only does it with double names */
|
|
||||||
sort_alpha_id(lbarray[a], id);
|
sort_alpha_id(lbarray[a], id);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
id= idn;
|
id= idn;
|
||||||
@@ -1410,7 +1400,7 @@ void all_local(Library *lib, int untagged_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* patch 3: make sure library data isn't indirect falsely... */
|
/* patch 3: make sure library data isn't indirect falsely... */
|
||||||
a= set_listbasepointers(G.main, lbarray);
|
a= set_listbasepointers(bmain, lbarray);
|
||||||
while(a--) {
|
while(a--) {
|
||||||
for(id= lbarray[a]->first; id; id=id->next)
|
for(id= lbarray[a]->first; id; id=id->next)
|
||||||
lib_indirect_test_id(id, lib);
|
lib_indirect_test_id(id, lib);
|
||||||
|
@@ -1713,6 +1713,7 @@ static void make_local_makelocalmaterial(Material *ma)
|
|||||||
|
|
||||||
static int make_local_exec(bContext *C, wmOperator *op)
|
static int make_local_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
|
Main *bmain= CTX_data_main(C);
|
||||||
AnimData *adt;
|
AnimData *adt;
|
||||||
ParticleSystem *psys;
|
ParticleSystem *psys;
|
||||||
Material *ma, ***matarar;
|
Material *ma, ***matarar;
|
||||||
@@ -1721,7 +1722,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
|
|||||||
int a, b, mode= RNA_enum_get(op->ptr, "type");
|
int a, b, mode= RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
if(mode==3) {
|
if(mode==3) {
|
||||||
all_local(NULL, 0); /* NULL is all libs */
|
BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */
|
||||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
@@ -310,13 +310,14 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item)
|
|||||||
|
|
||||||
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||||
{
|
{
|
||||||
|
Main *bmain= CTX_data_main(BPy_GetContext());
|
||||||
Main *mainl= NULL;
|
Main *mainl= NULL;
|
||||||
int err= 0;
|
int err= 0;
|
||||||
|
|
||||||
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
|
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
|
||||||
|
|
||||||
/* here appending/linking starts */
|
/* here appending/linking starts */
|
||||||
mainl= BLO_library_append_begin(CTX_data_main(BPy_GetContext()), &(self->blo_handle), self->relpath);
|
mainl= BLO_library_append_begin(bmain, &(self->blo_handle), self->relpath);
|
||||||
|
|
||||||
{
|
{
|
||||||
int i= 0, code;
|
int i= 0, code;
|
||||||
@@ -399,7 +400,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||||||
/* append, rather than linking */
|
/* append, rather than linking */
|
||||||
if ((self->flag & FILE_LINK)==0) {
|
if ((self->flag & FILE_LINK)==0) {
|
||||||
Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
|
Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
|
||||||
if (lib) all_local(lib, 1);
|
if (lib) BKE_library_make_local(bmain, lib, 1);
|
||||||
else BLI_assert(!"cant find name of just added library!");
|
else BLI_assert(!"cant find name of just added library!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1745,7 +1745,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
|||||||
/* append, rather than linking */
|
/* append, rather than linking */
|
||||||
if((flag & FILE_LINK)==0) {
|
if((flag & FILE_LINK)==0) {
|
||||||
Library *lib= BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
|
Library *lib= BLI_findstring(&bmain->library, libname, offsetof(Library, filepath));
|
||||||
if(lib) all_local(lib, 1);
|
if(lib) BKE_library_make_local(bmain, lib, 1);
|
||||||
else BLI_assert(!"cant find name of just added library!");
|
else BLI_assert(!"cant find name of just added library!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user