-
Notifications
You must be signed in to change notification settings - Fork 75
v0.2.55..v0.2.56 changeset JavaEnvironment.cpp
Garret Voltz edited this page Aug 14, 2020
·
3 revisions
diff --git a/hoot-josm/src/main/cpp/hoot/core/jni/JavaEnvironment.cpp b/hoot-josm/src/main/cpp/hoot/core/jni/JavaEnvironment.cpp
index 98a5d4b..782e339 100644
--- a/hoot-josm/src/main/cpp/hoot/core/jni/JavaEnvironment.cpp
+++ b/hoot-josm/src/main/cpp/hoot/core/jni/JavaEnvironment.cpp
@@ -37,30 +37,26 @@
namespace hoot
{
-JavaEnvironmentPtr JavaEnvironment::_theInstance;
-
JavaEnvironment::JavaEnvironment() :
_vm(0),
_env(0)
{
+ _initVm();
}
JavaEnvironment::~JavaEnvironment()
{
if (_vm != 0)
{
+ _vm->DetachCurrentThread();
_vm->DestroyJavaVM();
}
}
-const JavaEnvironmentPtr& JavaEnvironment::getInstance()
+JavaEnvironment& JavaEnvironment::getInstance()
{
- if (_theInstance.get() == 0)
- {
- _theInstance.reset(new JavaEnvironment());
- _theInstance->_initVm();
- }
- return _theInstance;
+ static JavaEnvironment instance;
+ return instance;
}
void JavaEnvironment::_initVm()