Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-28 08:44:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-28 08:44:59 +0400
commit4b635d16316d12dd4c57e1dcf99092551e6bbe35 (patch)
tree6ea23bd0fe40254564bad60d6113e4362c4f7dd1 /source/blender
parent3ad7445e28eaf36bf7a7907072205a757cc284d7 (diff)
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)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_library.h2
-rw-r--r--source/blender/blenkernel/intern/library.c34
-rw-r--r--source/blender/editors/object/object_relations.c3
-rw-r--r--source/blender/python/intern/bpy_library.c5
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
5 files changed, 19 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 59ced28d53e..e2033915caa 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -78,7 +78,7 @@ void rename_id(struct ID *id, const char *name);
void name_uiprefix_id(char *name, struct ID *id);
void test_idbutton(char *name);
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);
void clear_id_newpoins(void);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index d94e6f844a9..9d8acc44e88 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -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;}
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 */
-void all_local(Library *lib, int untagged_only)
+/* if lib!=NULL, only all from lib local
+ * 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};
ID *id, *idn;
int a;
- a= set_listbasepointers(G.main, lbarray);
+ a= set_listbasepointers(bmain, lbarray);
while(a--) {
id= lbarray[a]->first;
@@ -1385,17 +1376,16 @@ void all_local(Library *lib, int untagged_only)
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
{
if(lib==NULL || id->lib==lib) {
- id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
-
if(id->lib) {
- /* relative file patch */
- if(GS(id->name)==ID_IM)
- image_fix_relative_path((Image *)id);
-
- id->lib= NULL;
- new_id(lbarray[a], id, NULL); /* new_id only does it with double names */
+ id_clear_lib_data(bmain, id); /* sets 'id->flag' */
+
+ /* why sort alphabetically here but not in
+ * id_clear_lib_data() ? - campbell */
sort_alpha_id(lbarray[a], id);
}
+ else {
+ id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
+ }
}
}
id= idn;
@@ -1410,7 +1400,7 @@ void all_local(Library *lib, int untagged_only)
}
/* patch 3: make sure library data isn't indirect falsely... */
- a= set_listbasepointers(G.main, lbarray);
+ a= set_listbasepointers(bmain, lbarray);
while(a--) {
for(id= lbarray[a]->first; id; id=id->next)
lib_indirect_test_id(id, lib);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 7c049692b40..74da705965a 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1713,6 +1713,7 @@ static void make_local_makelocalmaterial(Material *ma)
static int make_local_exec(bContext *C, wmOperator *op)
{
+ Main *bmain= CTX_data_main(C);
AnimData *adt;
ParticleSystem *psys;
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");
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);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 651a626244f..382a513f40a 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -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))
{
+ Main *bmain= CTX_data_main(BPy_GetContext());
Main *mainl= NULL;
int err= 0;
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
/* 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;
@@ -399,7 +400,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
/* append, rather than linking */
if ((self->flag & FILE_LINK)==0) {
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!");
}
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a817761bd65..32d4ba857e6 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1745,7 +1745,7 @@ 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) all_local(lib, 1);
+ if(lib) BKE_library_make_local(bmain, lib, 1);
else BLI_assert(!"cant find name of just added library!");
}