HDF5 fixed about non initialization of static member 77/16377/2
Cedric Delamarre [Wed, 15 Apr 2015 15:51:44 +0000 (17:51 +0200)]
We can not be sure that the static member "nameToType"
will be initilize before the call of static methode "initMap".

Change-Id: I6b5f0fdeb24fb8dc3a8a5c282350d71bcd27c482

scilab/modules/hdf5/sci_gateway/cpp/hdf5_gw.cpp
scilab/modules/hdf5/src/cpp/H5Type.cpp
scilab/modules/hdf5/src/cpp/H5Type.hxx

index c872bed..2e022a4 100644 (file)
@@ -27,7 +27,6 @@ extern "C"
 /*--------------------------------------------------------------------------*/
 int Initialize(void)
 {
-    org_modules_hdf5::H5Type::initMap();
     org_modules_hdf5::H5VariableScope::initScope();
     org_modules_hdf5::H5Object::initRoot();
     return 0;
index 8486b23..17387b5 100644 (file)
@@ -15,7 +15,7 @@
 namespace org_modules_hdf5
 {
 
-std::map<std::string, hid_t> H5Type::nameToType;
+std::map<std::string, hid_t> H5Type::nameToType = initMap();
 
 void H5Type::init()
 {
index 7db1a27..7a067a3 100644 (file)
@@ -138,8 +138,10 @@ public:
         return (hid_t) - 1;
     }
 
-    static void initMap()
+    static std::map<std::string, hid_t> initMap()
     {
+        std::map<std::string, hid_t> nameToType;
+
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I8BE", H5T_STD_I8BE));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I8LE", H5T_STD_I8LE));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_STD_I16BE", H5T_STD_I16BE));
@@ -273,6 +275,8 @@ public:
         nameToType.insert(std::pair<std::string, hid_t>("H5T_VLEN", H5T_VLEN));
         nameToType.insert(std::pair<std::string, hid_t>("H5T_ARRAY", H5T_ARRAY));
         */
+
+        return nameToType;
     }
 
     static void cleanMap()