summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/native/IOSWindow.m15
-rw-r--r--src/newt/native/MacWindow.m17
2 files changed, 17 insertions, 15 deletions
diff --git a/src/newt/native/IOSWindow.m b/src/newt/native/IOSWindow.m
index 780c2344f..a8e816fbe 100644
--- a/src/newt/native/IOSWindow.m
+++ b/src/newt/native/IOSWindow.m
@@ -92,16 +92,18 @@ static int getRetainCount(NSObject * obj) {
}
#endif
-static void setJavaWindowObject(JNIEnv *env, jobject newJavaWindowObject, NewtUIView *view, BOOL enable) {
+static void setJavaWindowObject(JNIEnv *env, jobject newJavaWindowObject, NewtUIView *view) {
DBG_PRINT( "setJavaWindowObject.0: View %p\n", view);
- if( !enable) {
+ if( NULL == newJavaWindowObject ) {
+ // disable
jobject globJavaWindowObject = [view getJavaWindowObject];
if( NULL != globJavaWindowObject ) {
DBG_PRINT( "setJavaWindowObject.1: View %p - Clear old javaWindowObject %p\n", view, globJavaWindowObject);
(*env)->DeleteGlobalRef(env, globJavaWindowObject);
[view setJavaWindowObject: NULL];
}
- } else if( NULL != newJavaWindowObject ) {
+ } else {
+ // enable
DBG_PRINT( "setJavaWindowObject.2: View %p - Set new javaWindowObject %p\n", view, newJavaWindowObject);
jobject globJavaWindowObject = (*env)->NewGlobalRef(env, newJavaWindowObject);
[view setJavaWindowObject: globJavaWindowObject];
@@ -147,9 +149,8 @@ NS_ENDHANDLER
if( NULL!=newView ) {
[newView setDestroyNotifySent: false];
if( setJavaWindow ) {
- setJavaWindowObject(env, javaWindowObject, newView, YES);
+ setJavaWindowObject(env, javaWindowObject, newView);
}
-
DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d)\n",
dbgIdx++, win, oldUIView, getRetainCount(oldUIView), newView, getRetainCount(newView));
@@ -674,7 +675,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_ios_WindowDriver_initWindow0
dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
[myView setDestroyNotifySent: false];
- setJavaWindowObject(env, jthis, myView, YES);
+ setJavaWindowObject(env, jthis, myView);
DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n",
dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
@@ -790,7 +791,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_ios_WindowDriver_close0
if( isNewtUIView ) {
// cleanup view
[mView setDestroyNotifySent: true];
- setJavaWindowObject(env, NULL, mView, NO);
+ setJavaWindowObject(env, NULL, mView);
}
NS_DURING
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index ecacc74be..5775633be 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -101,16 +101,18 @@ static int getRetainCount(NSObject * obj) {
}
#endif
-static void setJavaWindowObject(JNIEnv *env, jobject newJavaWindowObject, NewtNSView *view, BOOL enable) {
+static void setJavaWindowObject(JNIEnv *env, jobject newJavaWindowObject, NewtNSView *view) {
DBG_PRINT( "setJavaWindowObject.0: View %p\n", view);
- if( !enable) {
+ if( NULL == newJavaWindowObject ) {
+ // disable
jobject globJavaWindowObject = [view getJavaWindowObject];
if( NULL != globJavaWindowObject ) {
DBG_PRINT( "setJavaWindowObject.1: View %p - Clear old javaWindowObject %p\n", view, globJavaWindowObject);
(*env)->DeleteGlobalRef(env, globJavaWindowObject);
[view setJavaWindowObject: NULL];
}
- } else if( NULL != newJavaWindowObject ) {
+ } else {
+ // enable
DBG_PRINT( "setJavaWindowObject.2: View %p - Set new javaWindowObject %p\n", view, newJavaWindowObject);
jobject globJavaWindowObject = (*env)->NewGlobalRef(env, newJavaWindowObject);
[view setJavaWindowObject: globJavaWindowObject];
@@ -151,7 +153,7 @@ NS_ENDHANDLER
if( NULL != oldNewtNSView ) {
[oldNewtNSView setDestroyNotifySent: false];
- setJavaWindowObject(env, NULL, oldNewtNSView, NO);
+ setJavaWindowObject(env, NULL, oldNewtNSView);
}
[oldNSView removeFromSuperviewWithoutNeedingDisplay];
}
@@ -161,9 +163,8 @@ NS_ENDHANDLER
if( NULL!=newView ) {
[newView setDestroyNotifySent: false];
if( setJavaWindow ) {
- setJavaWindowObject(env, javaWindowObject, newView, YES);
+ setJavaWindowObject(env, javaWindowObject, newView);
}
-
DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d)\n",
dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView));
@@ -993,7 +994,7 @@ NS_ENDHANDLER
dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
[myView setDestroyNotifySent: false];
- setJavaWindowObject(env, jthis, myView, YES);
+ setJavaWindowObject(env, jthis, myView);
DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n",
dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView);
@@ -1119,7 +1120,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0
if( isNewtNSView ) {
// cleanup view
[mView setDestroyNotifySent: true];
- setJavaWindowObject(env, NULL, mView, NO);
+ setJavaWindowObject(env, NULL, mView);
}
NS_DURING