mirror of
https://github.com/amwatson/CitraVR.git
synced 2024-09-20 03:11:40 +02:00
Fix incorrect deletion of VrUiLayerObject to remove memory error
This commit is contained in:
parent
c68b499ad9
commit
52fd1e1809
2 changed files with 17 additions and 15 deletions
|
@ -249,8 +249,10 @@ void UILayer::Shutdown() {
|
||||||
mSwapchain.mHeight = 0;
|
mSwapchain.mHeight = 0;
|
||||||
mEnv->DeleteGlobalRef(mVrUILayerClass);
|
mEnv->DeleteGlobalRef(mVrUILayerClass);
|
||||||
mVrUILayerClass = nullptr;
|
mVrUILayerClass = nullptr;
|
||||||
mEnv->DeleteGlobalRef(mVrUILayerObject);
|
// These steps are not strictly necessary for app shutdown, as references are cleaned up when
|
||||||
mVrUILayerClass = nullptr;
|
// the JVM is destroyed, but memory-saving if this class is destroyed/re-initialized at runtime.
|
||||||
|
mEnv->DeleteLocalRef(mVrUILayerObject);
|
||||||
|
mVrUILayerObject = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UILayer::CreateSwapchain() {
|
int UILayer::CreateSwapchain() {
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ public:
|
||||||
, mActivityObjectGlobalRef(jni->NewGlobalRef(activityObject)) {
|
, mActivityObjectGlobalRef(jni->NewGlobalRef(activityObject)) {
|
||||||
assert(jvm != nullptr);
|
assert(jvm != nullptr);
|
||||||
assert(activityObject != nullptr);
|
assert(activityObject != nullptr);
|
||||||
mThread = std::thread([this]() {ThreadFn();});
|
mThread = std::thread([this]() { ThreadFn(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
~VRAppThread() {
|
~VRAppThread() {
|
||||||
|
@ -1066,20 +1066,20 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ThreadFn() {
|
void ThreadFn() {
|
||||||
assert(mVm != nullptr);
|
assert(mVm != nullptr);
|
||||||
ALOGI("VRAppThread: starting");
|
ALOGI("VRAppThread: starting");
|
||||||
JNIEnv* jni = nullptr;
|
JNIEnv* jni = nullptr;
|
||||||
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
if (mVm->AttachCurrentThread(&jni, nullptr) != JNI_OK) {
|
||||||
FAIL("%s(): Could not attach to mVm", __FUNCTION__);
|
FAIL("%s(): Could not attach to mVm", __FUNCTION__);
|
||||||
}
|
}
|
||||||
// Gotta set this after the JNIEnv is attached, or else it'll be
|
// Gotta set this after the JNIEnv is attached, or else it'll be
|
||||||
// overwritten
|
// overwritten
|
||||||
prctl(PR_SET_NAME, (long)"CVR::Main", 0, 0, 0);
|
prctl(PR_SET_NAME, (long)"CVR::Main", 0, 0, 0);
|
||||||
|
|
||||||
ThreadFnJNI(jni);
|
ThreadFnJNI(jni);
|
||||||
|
|
||||||
mVm->DetachCurrentThread();
|
mVm->DetachCurrentThread();
|
||||||
ALOGI("VRAppThread: exited");
|
ALOGI("VRAppThread: exited");
|
||||||
}
|
}
|
||||||
|
|
||||||
// All operations assume that the JNIEnv is attached
|
// All operations assume that the JNIEnv is attached
|
||||||
|
|
Loading…
Reference in a new issue