From 969aec21520f4eff51554614bf00d5b30e68c356 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 15 Mar 2017 23:21:51 +0000 Subject: Don't rely on constructor/destructor order in templates, GCC runs them backwards! --- slicer/slicer/modelPartsTypes.h | 4 ++-- slicer/slicer/modelPartsTypes.impl.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 71736bf..cbd953e 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -191,8 +191,8 @@ namespace Slicer { static const std::string * typeName; static ModelPartPtr CreateModelPart(void *); - static void initClassName() __attribute__ ((constructor(209))); - static void deleteClassName() __attribute__ ((destructor(209))); + static void initClassName(); + static void deleteClassName(); static void registerClass() __attribute__ ((constructor(210))); static void unregisterClass() __attribute__ ((destructor(210))); }; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index f9d8a4f..08c14b2 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -288,6 +288,7 @@ namespace Slicer { template void ModelPartForClass::registerClass() { + initClassName(); ModelPartForComplexBase::registerClass(*className, typeName, &ModelPartForClass::CreateModelPart); } @@ -295,6 +296,7 @@ namespace Slicer { void ModelPartForClass::unregisterClass() { ModelPartForComplexBase::unregisterClass(*className, typeName); + deleteClassName(); } template -- cgit v1.2.3