< prev index next >

modules/javafx.graphics/src/main/native-glass/mac/GlassDialogs.m

Print this page

        

@@ -139,12 +139,16 @@
 - (void)runModally
 {
     GET_MAIN_JENV;
     DialogDispatcher *dd = self;
 
+    jclass eventLoopCls = [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env];
+    if (!eventLoopCls) {
+        return;
+    }
     jobject jobj = (*env)->NewObject(env,
-            [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env],
+            eventLoopCls,
             javaIDs.EventLoop.init);
     if ((*env)->ExceptionCheck(env)) return;
 
     dd->eventLoop = (*env)->NewGlobalRef(env, jobj);
 

@@ -248,20 +252,22 @@
 
     jobject ret = NULL;
 
     // Make sure the class is initialized before using the methodIDs
     const jclass MacCommonDialogsCls = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacCommonDialogs" withEnv:env];
+    if (!MacCommonDialogsCls) return NULL;
 
     // Performance doesn't matter here, so call the method every time
     jboolean result = (*env)->CallStaticBooleanMethod(env, MacCommonDialogsCls,
                 javaIDs.MacCommonDialogs.isFileNSURLEnabled);
     GLASS_CHECK_EXCEPTION(env);
     if (result)
     {
         [url retain]; //NOTE: an app must call MacFileURL.dispoes() to release it
 
         const jclass MacFileNSURLCls = [GlassHelper ClassForName:"com.sun.glass.ui.mac.MacFileNSURL" withEnv:env];
+        if (!MacFileNSURLCls) return NULL;
         ret = (*env)->NewObject(env,
                 MacFileNSURLCls,
                 javaIDs.MacFileNSURL.init, path, ptr_to_jlong(url));
         GLASS_CHECK_EXCEPTION(env);
         (*env)->DeleteLocalRef(env, MacFileNSURLCls);

@@ -432,10 +438,13 @@
 {
     javaIDs.MacCommonDialogs.isFileNSURLEnabled = (*env)->GetStaticMethodID(env, cls, "isFileNSURLEnabled", "()Z");
     if ((*env)->ExceptionCheck(env)) return;
 
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.EventLoop" withEnv:env];
+    if (!cls) {
+        return;
+    }
     javaIDs.EventLoop.init  = (*env)->GetMethodID(env, cls, "<init>", "()V");
     if ((*env)->ExceptionCheck(env)) return;
     javaIDs.EventLoop.enter = (*env)->GetMethodID(env, cls, "enter", "()Ljava/lang/Object;");
     if ((*env)->ExceptionCheck(env)) return;
     javaIDs.EventLoop.leave = (*env)->GetMethodID(env, cls, "leave", "(Ljava/lang/Object;)V");

@@ -444,16 +453,22 @@
     initJavaIDsList(env);
     initJavaIDsArrayList(env);
     initJavaIDsFile(env);
 
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$ExtensionFilter" withEnv:env];
+    if (!cls) {
+        return;
+    }
     javaIDs.ExtensionFilter.getDescription = (*env)->GetMethodID(env, cls, "getDescription", "()Ljava/lang/String;");
     if ((*env)->ExceptionCheck(env)) return;
     javaIDs.ExtensionFilter.extensionsToArray  = (*env)->GetMethodID(env, cls, "extensionsToArray", "()[Ljava/lang/String;");
     if ((*env)->ExceptionCheck(env)) return;
 
     cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$FileChooserResult" withEnv:env];
+    if (!cls) {
+        return;
+    }
     javaIDs.FileChooserResult.init = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/util/List;Lcom/sun/glass/ui/CommonDialogs$ExtensionFilter;)V");
 }
 
 /*
  * Class:     com_sun_glass_ui_mac_MacCommonDialogs

@@ -520,10 +535,11 @@
             }
         }
         [dispatcher release];
 
         cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$FileChooserResult" withEnv:env];
+        if (!cls) return NULL;
         result = (*env)->NewObject(env, cls, javaIDs.FileChooserResult.init, chosenFiles, chosenFilter);
     }
     GLASS_POOL_EXIT;
     GLASS_CHECK_EXCEPTION(env);
 

@@ -591,10 +607,11 @@
             }
         }
         [dispatcher release];
 
         cls = [GlassHelper ClassForName:"com.sun.glass.ui.CommonDialogs$FileChooserResult" withEnv:env];
+        if (!cls) return NULL;
         result = (*env)->NewObject(env, cls, javaIDs.FileChooserResult.init, chosenFile, chosenFilter);
     }
     GLASS_POOL_EXIT;
     GLASS_CHECK_EXCEPTION(env);
 
< prev index next >