summaryrefslogtreecommitdiffstats
path: root/src/newt/native/MacWindow.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/native/MacWindow.m')
-rw-r--r--src/newt/native/MacWindow.m17
1 files changed, 9 insertions, 8 deletions
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