mirror of
https://github.com/panda3d/panda3d.git
synced 2026-04-24 07:29:13 -05:00
retry on maya failure
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user