[Fwk] Static initializer must be placed at file global scope in order to always call the constructor in the cpp file

This commit is contained in:
Magne Sjaastad 2015-11-27 07:57:35 +01:00
parent 5c0c18ca30
commit 563aa95abf
2 changed files with 25 additions and 18 deletions

View File

@ -45,11 +45,6 @@
#include "cafPdmCoreColor3f.h"
class Color3fDummy
{
public:
Color3fDummy();
};
namespace caf
{
@ -61,8 +56,6 @@ public:
/// Convert the field value into a QVariant
static QVariant convert(const cvf::Color3f& value)
{
static Color3fDummy dummy;
return PdmValueFieldSpecialization< cvf::Color3f >::convert(value);
}
@ -92,3 +85,15 @@ public:
} // end namespace caf
//--------------------------------------------------------------------------------------------------
// If the macro for registering the editor is put as the single statement
// in a cpp file, a dummy static class must be used to make sure the compile unit
// is included
//--------------------------------------------------------------------------------------------------
class Color3fDummy
{
public:
Color3fDummy();
};
static Color3fDummy cafPdmColor3fDummy;

View File

@ -46,13 +46,6 @@
#include "cvfVector3.h"
class Vec3dDummy
{
public:
Vec3dDummy();
};
namespace caf
{
@ -63,12 +56,9 @@ public:
/// Convert the field value into a QVariant
static QVariant convert(const cvf::Vec3d& value)
{
static Vec3dDummy dummy;
return PdmValueFieldSpecialization< cvf::Vec3d >::convert(value);
}
/// Set the field value from a QVariant
static void setFromVariant(const QVariant& variantValue, cvf::Vec3d& value)
{
@ -89,8 +79,20 @@ public:
/// Methods to retrieve the possible PdmObject pointed to by a field
static void childObjects(const PdmDataValueField< cvf::Vec3d >&, std::vector<PdmObjectHandle*>*)
{ }
};
} // end namespace caf
//--------------------------------------------------------------------------------------------------
// If the macro for registering the editor is put as the single statement
// in a cpp file, a dummy static class must be used to make sure the compile unit
// is included
//--------------------------------------------------------------------------------------------------
class Vec3dDummy
{
public:
Vec3dDummy();
};
static Vec3dDummy cafPdmVec3dDummy;