Просмотр исходного кода

work around static init failure on windows

David Rose 22 лет назад
Родитель
Сommit
61008f86b7

+ 9 - 2
pandatool/src/mayaegg/config_mayaegg.cxx

@@ -35,12 +35,12 @@ ConfigureFn(config_mayaegg) {
 
 
 // Should we respect the Maya double-sided flag (true) or ignore it
 // Should we respect the Maya double-sided flag (true) or ignore it
 // and assume everything is single-sided (false)?
 // and assume everything is single-sided (false)?
-const bool maya_default_double_sided = config_mayaegg.GetBool("maya-default-double-sided", false);
+bool maya_default_double_sided;
 
 
 // Should we apply vertex color even when a texture is applied (true)
 // Should we apply vertex color even when a texture is applied (true)
 // or only when no texture is applied or the vertex-color egg flag is
 // or only when no texture is applied or the vertex-color egg flag is
 // set (false)?
 // set (false)?
-const bool maya_default_vertex_color = config_mayaegg.GetBool("maya-default-vertex-color", true);
+bool maya_default_vertex_color;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libmayaegg
 //     Function: init_libmayaegg
@@ -60,5 +60,12 @@ init_libmayaegg() {
 
 
   MayaEggGroupUserData::init_type();
   MayaEggGroupUserData::init_type();
   MayaNodeDesc::init_type();
   MayaNodeDesc::init_type();
+
+  // For some reason, static init is not reliably running when this is
+  // loaded as a plug-in of a plug-in.  Initialize these explicitly
+  // here.
+  maya_default_double_sided = config_mayaegg.GetBool("maya-default-double-sided", false);
+  maya_default_vertex_color = config_mayaegg.GetBool("maya-default-vertex-color", true);
+
 }
 }
 
 

+ 2 - 2
pandatool/src/mayaegg/config_mayaegg.h

@@ -24,8 +24,8 @@
 
 
 NotifyCategoryDeclNoExport(mayaegg);
 NotifyCategoryDeclNoExport(mayaegg);
 
 
-extern const bool maya_default_double_sided;
-extern const bool maya_default_vertex_color;
+extern bool maya_default_double_sided;
+extern bool maya_default_vertex_color;
 
 
 extern void init_libmayaegg();
 extern void init_libmayaegg();
 
 

+ 3 - 0
pandatool/src/mayaegg/mayaToEggConverter.cxx

@@ -84,6 +84,9 @@ MayaToEggConverter::
 MayaToEggConverter(const string &program_name) :
 MayaToEggConverter(const string &program_name) :
   _program_name(program_name)
   _program_name(program_name)
 {
 {
+  // Make sure the library is properly initialized.
+  init_libmayaegg();
+
   _from_selection = false;
   _from_selection = false;
   _polygon_output = false;
   _polygon_output = false;
   _polygon_tolerance = 0.01;
   _polygon_tolerance = 0.01;