Commit: 2c9c22df26dfdcf03bb308fdf35294ed79c2d0e5
Author: Gaia Clary
Date:   Sun Mar 11 20:32:47 2018 +0100
Branches: master
https://developer.blender.org/rB2c9c22df26dfdcf03bb308fdf35294ed79c2d0e5

fix Collada: wrong usage of pointer and hidden redeclaration

* Suspicious usage of pointer:

  short *type = 0; // this creates a null pointer

When this is later used for anything then blender would crash.
After following the code and check what happens i strongly believe
the author wanted to use a short and not a pointer to a short here.

* local variable where reused later in same function
While this did no harm, i still felt it was better to use a different
name here to make things more separated:

- moved variable declaraiotns into loop (for int a=0; ...)
- renamed uv_images to uv_image_set
- renamed index variable from i to j in inner loop that
  reused same index name from outer loop

===================================================================

M       source/blender/collada/DocumentImporter.cpp
M       source/blender/collada/GeometryExporter.cpp
M       source/blender/collada/ImageExporter.cpp
M       source/blender/collada/MeshImporter.cpp

===================================================================

diff --git a/source/blender/collada/DocumentImporter.cpp 
b/source/blender/collada/DocumentImporter.cpp
index 4837eb094d9..08ac6e65c11 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -474,9 +474,9 @@ void DocumentImporter::create_constraints(ExtraTags *et, 
Object *ob)
 {
        if (et && et->isProfile("blender")) {
                std::string name;
-               short* type = 0;
-               et->setData("type", type);
-               BKE_constraint_add_for_object(ob, "Test_con", *type);
+               short type = 0;
+               et->setData("type", &type);
+               BKE_constraint_add_for_object(ob, "Test_con", type);
                
        }
 }
@@ -587,8 +587,8 @@ std::vector<Object *> 
*DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
                        ++lamp_done;
                }
                while (controller_done < controller.getCount()) {
-                       COLLADAFW::InstanceGeometry *geom = 
(COLLADAFW::InstanceGeometry *)controller[controller_done];
-                       ob = mesh_importer.create_mesh_object(node, geom, true, 
uid_material_map, material_texture_mapping_map);
+                       COLLADAFW::InstanceGeometry *geometry = 
(COLLADAFW::InstanceGeometry *)controller[controller_done];
+                       ob = mesh_importer.create_mesh_object(node, geometry, 
true, uid_material_map, material_texture_mapping_map);
                        if (ob == NULL) {
                                report_unknown_reference(*node, 
"instance_controller");
                        }
diff --git a/source/blender/collada/GeometryExporter.cpp 
b/source/blender/collada/GeometryExporter.cpp
index 73b00fd07ec..bc0275001d3 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -149,8 +149,8 @@ void GeometryExporter::operator()(Object *ob)
                }
                else {
                        bool all_uv_layers = 
!this->export_settings->active_uv_only;
-                       std::set<Image *> uv_images = bc_getUVImages(ob, 
all_uv_layers);
-                       createPolylists(uv_images, has_uvs, has_color, ob, me, 
geom_id, norind);
+                       std::set<Image *> uv_image_set = bc_getUVImages(ob, 
all_uv_layers);
+                       createPolylists(uv_image_set, has_uvs, has_color, ob, 
me, geom_id, norind);
                }
        }
        
diff --git a/source/blender/collada/ImageExporter.cpp 
b/source/blender/collada/ImageExporter.cpp
index 93be7de6236..99547551a12 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -203,8 +203,8 @@ bool ImagesExporter::hasImages(Scene *sce)
        
        for (node = this->export_settings->export_set; node; node = node->next) 
{
                Object *ob = (Object *)node->link;
-               int a;
-               for (a = 0; a < ob->totcol; a++) {
+
+               for (int a = 0; a < ob->totcol; a++) {
                        Material *ma = give_current_material(ob, a + 1);
 
                        // no material, but check all of the slots
diff --git a/source/blender/collada/MeshImporter.cpp 
b/source/blender/collada/MeshImporter.cpp
index 6ca53c64299..2e265125a43 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -552,7 +552,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
 {
        CustomData edata;
        MEdge *medge;
-       int i, totedge;
+       int totedge;
 
        if (len == 0)
                return;
@@ -572,7 +572,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
 
        /* set default flags */
        medge = &mesh->medge[mesh->totedge];
-       for (i = 0; i < len; i++, medge++)
+       for (int i = 0; i < len; i++, medge++)
                medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
 
        mesh->totedge = totedge;
@@ -606,12 +606,12 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh 
*me)
                                unsigned int edge_count  = mp->getFaceCount();
                                unsigned int *indices    = 
mp->getPositionIndices().getData();
                                
-                               for (int i = 0; i < edge_count; i++, med++) {
+                               for (int j = 0; j < edge_count; j++, med++) {
                                        med->bweight = 0;
                                        med->crease  = 0;
                                        med->flag   |= ME_LOOSEEDGE;
-                                       med->v1      = indices[2 * i];
-                                       med->v2      = indices[2 * i + 1];
+                                       med->v1      = indices[2 * j];
+                                       med->v2      = indices[2 * j + 1];
                                }
                        }
                }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to