[Bf-blender-cvs] [1107af1abb0] master: Fix OBJECT_GUARDED_FREE compiler error when type is in namespace

Brecht Van Lommel noreply at git.blender.org
Mon Jan 27 12:26:07 CET 2020


Commit: 1107af1abb0d4bf271e995a18f5d4bd790d51d02
Author: Brecht Van Lommel
Date:   Sun Jan 26 16:38:18 2020 +0100
Branches: master
https://developer.blender.org/rB1107af1abb0d4bf271e995a18f5d4bd790d51d02

Fix OBJECT_GUARDED_FREE compiler error when type is in namespace

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

M	intern/guardedalloc/MEM_guardedalloc.h
M	source/blender/alembic/intern/abc_curves.cc
M	source/blender/alembic/intern/abc_hair.cc
M	source/blender/alembic/intern/abc_mball.cc
M	source/blender/alembic/intern/abc_mesh.cc
M	source/blender/alembic/intern/abc_nurbs.cc
M	source/blender/alembic/intern/alembic_capi.cc
M	source/blender/collada/BCAnimationCurve.h
M	source/blender/collada/DocumentExporter.cpp
M	source/blender/collada/DocumentImporter.cpp
M	source/blender/collada/MeshImporter.cpp
M	source/blender/collada/collada_utils.cpp
M	source/blender/compositor/operations/COM_CompositorOperation.cpp
M	source/blender/compositor/operations/COM_ImageOperation.h
M	source/blender/compositor/operations/COM_OutputFileOperation.cpp
M	source/blender/compositor/operations/COM_PreviewOperation.cpp
M	source/blender/compositor/operations/COM_RenderLayersProg.h
M	source/blender/compositor/operations/COM_SplitOperation.cpp
M	source/blender/compositor/operations/COM_TextureOperation.h
M	source/blender/compositor/operations/COM_ViewerOperation.cpp
M	source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M	source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
M	source/blender/freestyle/intern/system/PythonInterpreter.h
M	source/blender/imbuf/intern/oiio/openimageio_api.cpp
M	source/blender/imbuf/intern/openexr/openexr_api.cpp
M	source/blender/physics/intern/BPH_mass_spring.cpp
M	source/blender/usd/intern/usd_capi.cc
M	tests/gtests/blenlib/BLI_array_store_test.cc
M	tests/gtests/blenlib/BLI_delaunay_2d_test.cc
M	tests/gtests/blenlib/BLI_ghash_performance_test.cc
M	tests/gtests/blenlib/BLI_heap_simple_test.cc
M	tests/gtests/blenlib/BLI_heap_test.cc
M	tests/gtests/blenlib/BLI_kdopbvh_test.cc
M	tests/gtests/blenlib/BLI_listbase_test.cc
M	tests/gtests/blenlib/BLI_memiter_test.cc
M	tests/gtests/blenlib/BLI_polyfill_2d_test.cc
M	tests/gtests/blenlib/BLI_task_performance_test.cc
M	tests/gtests/blenlib/BLI_task_test.cc
M	tests/gtests/blenloader/blendfile_loading_base_test.cc

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

diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index b1a0eda0e22..958e5ae86cd 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -230,6 +230,10 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
 /* Switch allocator to slower but fully guarded mode. */
 void MEM_use_guarded_allocator(void);
 
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 #ifdef __cplusplus
 /* alloc funcs for C++ only */
 #  define MEM_CXX_CLASS_ALLOC_FUNCS(_id) \
@@ -253,6 +257,13 @@ void MEM_use_guarded_allocator(void);
         MEM_freeN(mem); \
     }
 
+/* Needed when type includes a namespace, then the namespace should not be
+ * specified after ~, so using a macro fails. */
+template<class T> inline void OBJECT_GUARDED_DESTRUCTOR(T *what)
+{
+  what->~T();
+}
+
 #  if defined __GNUC__
 #    define OBJECT_GUARDED_NEW(type, args...) new (MEM_mallocN(sizeof(type), __func__)) type(args)
 #  else
@@ -262,15 +273,11 @@ void MEM_use_guarded_allocator(void);
 #  define OBJECT_GUARDED_DELETE(what, type) \
     { \
       if (what) { \
-        ((type *)(what))->~type(); \
+        OBJECT_GUARDED_DESTRUCTOR((type *)what); \
         MEM_freeN(what); \
       } \
     } \
     (void)0
 #endif /* __cplusplus */
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
 #endif /* __MEM_GUARDEDALLOC_H__ */
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 50aa13bea4f..3b143356c04 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -28,9 +28,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
 
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 98387be2e61..7eaecd271f4 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -25,9 +25,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc
index 732ceffe467..db4b9d82ebf 100644
--- a/source/blender/alembic/intern/abc_mball.cc
+++ b/source/blender/alembic/intern/abc_mball.cc
@@ -22,6 +22,8 @@
 #include "abc_mesh.h"
 #include "abc_transform.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_meta_types.h"
 #include "DNA_mesh_types.h"
@@ -35,7 +37,6 @@ extern "C" {
 #include "BKE_object.h"
 
 #include "DEG_depsgraph.h"
-#include "MEM_guardedalloc.h"
 }
 
 AbcMBallWriter::AbcMBallWriter(Main *bmain,
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index edcb6263da3..3eee390d7d3 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -25,6 +25,8 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
@@ -46,8 +48,6 @@ extern "C" {
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 
-#include "MEM_guardedalloc.h"
-
 #include "WM_api.h"
 #include "WM_types.h"
 
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index 739276dffa6..c11ca7d57b9 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -23,9 +23,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
 
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 5efa8c8a446..5519cbef53c 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -32,9 +32,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_cachefile_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_modifier_types.h"
diff --git a/source/blender/collada/BCAnimationCurve.h b/source/blender/collada/BCAnimationCurve.h
index 4651290ea0f..7b523ac53ca 100644
--- a/source/blender/collada/BCAnimationCurve.h
+++ b/source/blender/collada/BCAnimationCurve.h
@@ -23,8 +23,9 @@
 #include "collada_utils.h"
 #include "BCSampleData.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
+
+extern "C" {
 #include "BKE_fcurve.h"
 #include "BKE_armature.h"
 #include "BKE_material.h"
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp
index 0ebcd6d0919..24a960ab287 100644
--- a/source/blender/collada/DocumentExporter.cpp
+++ b/source/blender/collada/DocumentExporter.cpp
@@ -56,6 +56,8 @@
 #include "COLLADASWInstanceNode.h"
 #include "COLLADASWBaseInputElement.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
@@ -99,8 +101,6 @@ extern char build_commit_time[];
 extern char build_hash[];
 #endif
 
-#include "MEM_guardedalloc.h"
-
 #include "RNA_access.h"
 }
 
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 30e41a8d720..f2c52b125a4 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -43,6 +43,8 @@
 #include "COLLADASaxFWLLoader.h"
 #include "COLLADASaxFWLIExtraDataCallbackHandler.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "BLI_listbase.h"
 #include "BLI_math.h"
@@ -68,8 +70,6 @@ extern "C" {
 
 #include "RNA_access.h"
 
-#include "MEM_guardedalloc.h"
-
 #include "WM_api.h"
 #include "WM_types.h"
 }
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index e02a7a014f1..8ed30a0dc81 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -31,6 +31,8 @@
 #include "COLLADAFWMeshVertexData.h"
 #include "COLLADAFWPolygons.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "BKE_customdata.h"
 #include "BKE_displist.h"
@@ -44,8 +46,6 @@ extern "C" {
 #include "BLI_math.h"
 #include "BLI_string.h"
 #include "BLI_edgehash.h"
-
-#include "MEM_guardedalloc.h"
 }
 
 #include "ArmatureImporter.h"
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index d5011581204..5db4609c7c2 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -27,6 +27,9 @@
 
 #include <set>
 #include <string>
+
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_modifier_types.h"
 #include "DNA_customdata_types.h"
@@ -62,8 +65,6 @@ extern "C" {
 #include "ED_node.h"
 #include "ED_object.h"
 
-#include "MEM_guardedalloc.h"
-
 #include "WM_api.h" /* XXX hrm, see if we can do without this */
 #include "WM_types.h"
 
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 5bd466658c0..ff9fc7dbcbc 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -17,6 +17,7 @@
  */
 
 #include "COM_CompositorOperation.h"
+#include "MEM_guardedalloc.h"
 #include "BLI_listbase.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
@@ -26,7 +27,6 @@ extern "C" {
 #include "RE_pipeline.h"
 #include "RE_shader_ext.h"
 #include "RE_render_ext.h"
-#include "MEM_guardedalloc.h"
 #include "render_types.h"
 }
 #include "PIL_time.h"
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index e03173dca8d..6237d336c74 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -20,13 +20,13 @@
 #define __COM_IMAGEOPERATION_H__
 
 #include "COM_NodeOperation.h"
+#include "MEM_guardedalloc.h"
 #include "BLI_listbase.h"
 #include "BKE_image.h"
 extern "C" {
 #include "RE_pipeline.h"
 #include "RE_shader_ext.h"
 #include "RE_render_ext.h"
-#include "MEM_guardedalloc.h"
 }
 
 /**
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index c06994d7cdb..334eab6ef95 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -30,9 +30,9 @@
 #include "BKE_scene.h"
 
 #include "DNA_color_types.h"
+#include "MEM_guardedalloc.h"
 
 extern "C" {
-#include "MEM_guardedalloc.h"
 #include "IMB_imbuf.h"
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index cd2bb3b2928..b91c3324f87 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -26,8 +26,8 @@
 #include "BLI_math_color.h"
 #include "COM_defines.h"
 #include "BLI_math.h"
-extern "C" {
 #include "MEM_guardedalloc.h"
+extern "C" {
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 #include "IMB_colormanagement.h"
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index 5aa7e879760..ca7c18a0586 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -20,12 +20,12 @@
 #define __COM_RENDERLAYERSPROG_H__
 
 #include "COM_NodeOperation.h"
+#include "MEM_guardedalloc.h"
 #include "DNA_scene_types.h"
 #include "BLI_listbase.h"
 #include "BKE_image.h"
 extern "C" {
 #include "RE_pipeline.h"
-#include "MEM_guardedalloc.h"
 }
 
 /**
diff --git a/source/blender/compositor/operations/COM_SplitOp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list