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>2016-07-18 12:25:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-07-18 12:25:44 +0300
commit9186b9ae4806f4bbc1a14417c408e844f8e8cc1a (patch)
tree117bbd4ace75825e3a65f0ba2a447509bde0df85 /source/blender/blenloader
parentcfbd605567f48229a923df382baf6db98fbafc61 (diff)
parent9946cca14676bf07b3c7c103e99033fe1e4e423e (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c76
-rw-r--r--source/blender/blenloader/intern/readfile.h2
-rw-r--r--source/blender/blenloader/intern/versioning_270.c13
-rw-r--r--source/blender/blenloader/intern/writefile.c8
4 files changed, 49 insertions, 50 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5d0de6526b6..a7c625b0842 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -907,7 +907,10 @@ static void decode_blender_header(FileData *fd)
}
}
-static int read_file_dna(FileData *fd)
+/**
+ * \return Success if the file is read correctly, else set \a r_error_message.
+ */
+static bool read_file_dna(FileData *fd, const char **r_error_message)
{
BHead *bhead;
@@ -915,20 +918,25 @@ static int read_file_dna(FileData *fd)
if (bhead->code == DNA1) {
const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0;
- fd->filesdna = DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap, true);
+ fd->filesdna = DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap, true, r_error_message);
if (fd->filesdna) {
fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
/* used to retrieve ID names from (bhead+1) */
fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
+
+ return true;
+ }
+ else {
+ return false;
}
- return 1;
}
else if (bhead->code == ENDB)
break;
}
- return 0;
+ *r_error_message = "Missing DNA block";
+ return false;
}
static int *read_file_thumbnail(FileData *fd)
@@ -1070,13 +1078,9 @@ static FileData *filedata_new(void)
fd->filedes = -1;
fd->gzfiledes = NULL;
-
- /* XXX, this doesn't need to be done all the time,
- * but it keeps us re-entrant, remove once we have
- * a lib that provides a nice lock. - zr
- */
- fd->memsdna = DNA_sdna_from_data(DNAstr, DNAlen, false, false);
-
+
+ fd->memsdna = DNA_sdna_current_get();
+
fd->datamap = oldnewmap_new();
fd->globmap = oldnewmap_new();
fd->libmap = oldnewmap_new();
@@ -1089,8 +1093,11 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
decode_blender_header(fd);
if (fd->flags & FD_FLAGS_FILE_OK) {
- if (!read_file_dna(fd)) {
- BKE_reportf(reports, RPT_ERROR, "Failed to read blend file '%s', incomplete", fd->relabase);
+ const char *error_message = NULL;
+ if (read_file_dna(fd, &error_message) == false) {
+ BKE_reportf(reports, RPT_ERROR,
+ "Failed to read blend file '%s': %s",
+ fd->relabase, error_message);
blo_freefiledata(fd);
fd = NULL;
}
@@ -1267,9 +1274,7 @@ void blo_freefiledata(FileData *fd)
// Free all BHeadN data blocks
BLI_freelistN(&fd->listbase);
-
- if (fd->memsdna)
- DNA_sdna_free(fd->memsdna);
+
if (fd->filesdna)
DNA_sdna_free(fd->filesdna);
if (fd->compflags)
@@ -1842,7 +1847,7 @@ void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
/* ********** END OLD POINTERS ****************** */
/* ********** READ FILE ****************** */
-static void switch_endian_structs(struct SDNA *filesdna, BHead *bhead)
+static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead)
{
int blocksize, nblocks;
char *data;
@@ -2137,6 +2142,7 @@ static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_p
}
prv->gputexture[i] = NULL;
}
+ prv->icon_id = 0;
}
return prv;
@@ -2705,7 +2711,7 @@ static void lib_link_node_socket(FileData *fd, ID *UNUSED(id), bNodeSocket *sock
IDP_LibLinkProperty(sock->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
-/* singe node tree (also used for material/scene trees), ntree is not NULL */
+/* Single node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
{
bNode *node;
@@ -2748,22 +2754,6 @@ static void lib_link_nodetree(FileData *fd, Main *main)
}
}
-/* get node tree stored locally in other IDs */
-static bNodeTree *nodetree_from_id(ID *id)
-{
- if (!id)
- return NULL;
- switch (GS(id->name)) {
- case ID_SCE: return ((Scene *)id)->nodetree;
- case ID_MA: return ((Material *)id)->nodetree;
- case ID_WO: return ((World *)id)->nodetree;
- case ID_LA: return ((Lamp *)id)->nodetree;
- case ID_TE: return ((Tex *)id)->nodetree;
- case ID_LS: return ((FreestyleLineStyle *)id)->nodetree;
- }
- return NULL;
-}
-
/* updates group node socket identifier so that
* external links to/from the group node are preserved.
*/
@@ -5957,11 +5947,9 @@ static void lib_link_screen(FileData *fd, Main *main)
snode->id = newlibadr(fd, sc->id.lib, snode->id);
snode->from = newlibadr(fd, sc->id.lib, snode->from);
- ntree = nodetree_from_id(snode->id);
- if (ntree)
- snode->nodetree = ntree;
- else {
- snode->nodetree = newlibadr_us(fd, sc->id.lib, snode->nodetree);
+ if (snode->id) {
+ ntree = ntreeFromID(snode->id);
+ snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree);
}
for (path = snode->treepath.first; path; path = path->next) {
@@ -6341,11 +6329,11 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
snode->id = restore_pointer_by_name(id_map, snode->id, USER_REAL);
snode->from = restore_pointer_by_name(id_map, snode->from, USER_IGNORE);
- ntree = nodetree_from_id(snode->id);
- if (ntree)
- snode->nodetree = ntree;
- else
- snode->nodetree = restore_pointer_by_name(id_map, (ID*)snode->nodetree, USER_REAL);
+ if (snode->id) {
+ ntree = ntreeFromID(snode->id);
+ snode->nodetree = ntree ? ntree :
+ restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL);
+ }
for (path = snode->treepath.first; path; path = path->next) {
if (path == snode->treepath.first) {
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 42728fd406f..b054cd0031d 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -74,7 +74,7 @@ typedef struct FileData {
// general reading variables
struct SDNA *filesdna;
- struct SDNA *memsdna;
+ const struct SDNA *memsdna;
char *compflags; /* array of eSDNA_StructCompare */
int fileversion;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index d631e1507e3..81b61f399c9 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1130,5 +1130,18 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
+ Object *ob;
+ for (ob = main->object.first; ob; ob = ob->id.next) {
+ ModifierData *md;
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Boolean) {
+ BooleanModifierData *bmd = (BooleanModifierData *)md;
+ bmd->double_threshold = 1e-6f;
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 9c7aa87f3cc..c9f4858e545 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -301,7 +301,7 @@ static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
typedef struct {
- struct SDNA *sdna;
+ const struct SDNA *sdna;
unsigned char *buf;
MemFile *compare, *current;
@@ -323,7 +323,7 @@ static WriteData *writedata_new(WriteWrap *ww)
{
WriteData *wd = MEM_callocN(sizeof(*wd), "writedata");
- wd->sdna = DNA_sdna_from_data(DNAstr, DNAlen, false, false);
+ wd->sdna = DNA_sdna_current_get();
wd->ww = ww;
@@ -355,8 +355,6 @@ static void writedata_do_write(WriteData *wd, const void *mem, int memlen)
static void writedata_free(WriteData *wd)
{
- DNA_sdna_free(wd->sdna);
-
MEM_freeN(wd->buf);
MEM_freeN(wd);
}
@@ -2042,7 +2040,7 @@ static void write_meshes(WriteData *wd, ListBase *idbase)
mesh->edit_btmesh = NULL;
/* now fill in polys to mfaces */
- /* XXX This breaks writing desing, by using temp allocated memory, which will likely generate
+ /* XXX This breaks writing design, by using temp allocated memory, which will likely generate
* duplicates in stored 'old' addresses.
* This is very bad, but do not see easy way to avoid this, aside from generating those data
* outside of save process itself.