Esempio n. 1
0
/* if lib!=NULL, only all from lib local */
void all_local(Library *lib, int untagged_only)
{
	ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
	ID *id, *idn;
	int a;

	a= set_listbasepointers(G.main, lbarray);
	while(a--) {
		id= lbarray[a]->first;
		
		while(id) {
			id->newid= NULL;
			idn= id->next;		/* id is possibly being inserted again */
			
			/* The check on the second line (LIB_PRE_EXISTING) is done so its
			 * possible to tag data you dont want to be made local, used for
			 * appending data, so any libdata already linked wont become local
			 * (very nasty to discover all your links are lost after appending)  
			 * */
			if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
			  (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 */
						sort_alpha_id(lbarray[a], id);
					}
				}
			}
			id= idn;
		}
		
		/* patch2: make it aphabetically */
		while( (id=tempbase.first) ) {
			BLI_remlink(&tempbase, id);
			BLI_addtail(lbarray[a], id);
			new_id(lbarray[a], id, NULL);
		}
	}

	/* patch 3: make sure library data isn't indirect falsely... */
	a= set_listbasepointers(G.main, lbarray);
	while(a--) {
		for(id= lbarray[a]->first; id; id=id->next)
			lib_indirect_test_id(id, lib);
	}
}
Esempio n. 2
0
/* 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(bmain, lbarray);
    while (a--) {
        id = lbarray[a]->first;

        while (id) {
            id->newid = NULL;
            idn = id->next;      /* id is possibly being inserted again */

            /* The check on the second line (LIB_PRE_EXISTING) is done so its
             * possible to tag data you don't want to be made local, used for
             * appending data, so any libdata already linked wont become local
             * (very nasty to discover all your links are lost after appending)
             * */
            if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
                    (untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING)))
            {
                if (lib == NULL || id->lib == lib) {
                    if (id->lib) {
                        id_clear_lib_data(bmain, id); /* sets 'id->flag' */

                        /* why sort alphabetically here but not in
                         * id_clear_lib_data() ? - campbell */
                        id_sort_by_name(lbarray[a], id);
                    }
                    else {
                        id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
                    }
                }
            }
            id = idn;
        }

        /* patch2: make it aphabetically */
        while ( (id = tempbase.first) ) {
            BLI_remlink(&tempbase, id);
            BLI_addtail(lbarray[a], id);
            new_id(lbarray[a], id, NULL);
        }
    }

    /* patch 3: make sure library data isn't indirect falsely... */
    a = set_listbasepointers(bmain, lbarray);
    while (a--) {
        for (id = lbarray[a]->first; id; id = id->next)
            lib_indirect_test_id(id, lib);
    }
}
Esempio n. 3
0
/* if lib!=NULL, only all from lib local
 * bmain is almost certainly G.main */
void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
{
	ListBase *lbarray[MAX_LIBARRAY];
	ID *id, *idn;
	int a;

	a = set_listbasepointers(bmain, lbarray);
	while (a--) {
		id = lbarray[a]->first;
		
		while (id) {
			id->newid = NULL;
			idn = id->next;      /* id is possibly being inserted again */
			
			/* The check on the second line (LIB_PRE_EXISTING) is done so its
			 * possible to tag data you don't want to be made local, used for
			 * appending data, so any libdata already linked wont become local
			 * (very nasty to discover all your links are lost after appending)  
			 * */
			if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
			    ((untagged_only == false) || !(id->flag & LIB_PRE_EXISTING)))
			{
				if (lib == NULL || id->lib == lib) {
					if (id->lib) {
						/* for Make Local > All we should be calling id_make_local,
						 * but doing that breaks append (see #36003 and #36006), we
						 * we should make it work with all datablocks and id.us==0 */
						id_clear_lib_data(bmain, id); /* sets 'id->flag' */

						/* why sort alphabetically here but not in
						 * id_clear_lib_data() ? - campbell */
						id_sort_by_name(lbarray[a], id);
					}
					else {
						id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
					}
				}
			}
			id = idn;
		}
	}

	a = set_listbasepointers(bmain, lbarray);
	while (a--) {
		for (id = lbarray[a]->first; id; id = id->next)
			lib_indirect_test_id(id, lib);
	}
}