diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-01-06 23:16:06 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-01-06 23:16:06 +0300 |
commit | 36e03e5ca8278bf68ebf42c412ab727d43215654 (patch) | |
tree | 8cdea534706a9d92d1cae9e22780fe240091b268 /source/blender/blenkernel | |
parent | 6128b510234bc67d10b55aed9fbb66f304d7c849 (diff) |
Potential fix for bug #5359:
Crash leaving editmode related to vertex groups. I couldn't reproduce this,
but suspect somehow multiple deformvert layers were created. Added some
extra checks to avoid that now.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_customdata.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 30 |
2 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 03224eaadaf..542837dc3fb 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -221,4 +221,8 @@ const char *CustomData_layertype_name(int type); /* make sure the name of layer at index is unique */ void CustomData_set_layer_unique_name(struct CustomData *data, int index); +/* for file reading compatibility, returns false if the layer was freed, + only after this test passes, layer->data should be assigned */ +int CustomData_verify_versions(struct CustomData *data, int index); + #endif diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e93a58bc951..b6bcce96ad4 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -567,6 +567,9 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int size = typeInfo->size * totelem, flag = 0, index = data->totlayer; void *newlayerdata; + if (!typeInfo->defaultname && CustomData_has_layer(data, type)) + return &data->layers[CustomData_get_layer_index(data, type)]; + if((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) { newlayerdata = layerdata; } @@ -644,7 +647,6 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype, void *layerdata, int totelem, char *name) { CustomDataLayer *layer; - const LayerTypeInfo *typeInfo= layerType_getInfo(type); layer = customData_add_layer__internal(data, type, alloctype, layerdata, totelem, name); @@ -1289,3 +1291,29 @@ void CustomData_set_layer_unique_name(CustomData *data, int index) } } +int CustomData_verify_versions(struct CustomData *data, int index) +{ + const LayerTypeInfo *typeInfo; + CustomDataLayer *layer = &data->layers[index]; + int i, keeplayer = 1; + + if (layer->type >= CD_NUMTYPES) { + keeplayer = 0; /* unknown layer type from future version */ + } + else { + typeInfo = layerType_getInfo(layer->type); + + if (!typeInfo->defaultname && (index > 0) && + data->layers[index-1].type == layer->type) + keeplayer = 0; /* multiple layers of which we only support one */ + } + + if (!keeplayer) { + for (i=index+1; i < data->totlayer; ++i) + data->layers[i-1] = data->layers[i]; + data->totlayer--; + } + + return keeplayer; +} + |