David Rose пре 17 година
родитељ
комит
78cc74bdf1

+ 10 - 0
pandatool/src/maya/config_maya.cxx

@@ -23,6 +23,16 @@ ConfigureFn(config_maya) {
   init_libmaya();
 }
 
+ConfigVariableInt init_maya_repeat_count
+("init-maya-repeat-count", 5,
+ PRC_DESC("The number of times to attempt to initialize Maya and acquire the "
+          "Maya license before giving up."));
+
+ConfigVariableDouble init_maya_timeout
+("init-maya-timeout", 5.0,
+ PRC_DESC("The number of seconds to wait between attempts to acquire the "
+          "Maya license."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libmaya
 //  Description: Initializes the library.  This must be called at

+ 5 - 0
pandatool/src/maya/config_maya.h

@@ -17,9 +17,14 @@
 
 #include "pandatoolbase.h"
 #include "notifyCategoryProxy.h"
+#include "configVariableInt.h"
+#include "configVariableDouble.h"
 
 NotifyCategoryDeclNoExport(maya);
 
+extern ConfigVariableInt init_maya_repeat_count;
+extern ConfigVariableDouble init_maya_timeout;
+
 extern void init_libmaya();
 
 #endif

+ 9 - 0
pandatool/src/maya/mayaApi.cxx

@@ -15,6 +15,7 @@
 #include "mayaApi.h"
 #include "config_maya.h"
 #include "string_utils.h"
+#include "thread.h"
 
 #include "pre_maya_include.h"
 #include <maya/MGlobal.h>
@@ -65,6 +66,14 @@ MayaApi(const string &program_name) {
   // any Maya function!  Egad!
   _cwd = ExecutionEnvironment::get_cwd();
   MStatus stat = MLibrary::initialize((char *)program_name.c_str());
+
+  int error_count = init_maya_repeat_count;
+  while (!stat && error_count > 1) {
+    stat.perror("MLibrary::initialize");
+    Thread::sleep(init_maya_timeout);
+    stat = MLibrary::initialize((char *)program_name.c_str());
+    --error_count;
+  }
   
   // Restore the current directory.
   string dirname = _cwd.to_os_specific();