< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_FileDialog.cpp

Print this page




 242 {
 243     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 244     jobject peer;
 245     LPTSTR fileBuffer = NULL;
 246     LPTSTR currentDirectory = NULL;
 247     jint mode = 0;
 248     BOOL result = FALSE;
 249     DWORD dlgerr;
 250     jstring directory = NULL;
 251     jstring title = NULL;
 252     jstring file = NULL;
 253     jobject fileFilter = NULL;
 254     jobject target = NULL;
 255     jobject parent = NULL;
 256     AwtComponent* awtParent = NULL;
 257     jboolean multipleMode = JNI_FALSE;
 258 
 259     OPENFILENAME ofn;
 260     memset(&ofn, 0, sizeof(ofn));
 261 
 262     /*
 263      * There's a situation (see bug 4906972) when InvokeFunction (by which this method is called)
 264      * returnes earlier than this method returnes. Probably it's caused due to ReplyMessage system call.
 265      * So for the avoidance of this mistiming we need to make new global reference here
 266      * (not local as it's used by the hook) and then manage it independently of the calling thread.
 267      */
 268     peer = env->NewGlobalRef((jobject)p);
 269 
 270     try {
 271         DASSERT(peer);
 272         target = env->GetObjectField(peer, AwtObject::targetID);
 273         parent = env->GetObjectField(peer, AwtFileDialog::parentID);
 274         if (parent != NULL) {
 275             awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
 276         }
 277 //      DASSERT(awtParent);
 278         title = (jstring)(env)->GetObjectField(target, AwtDialog::titleID);
 279         HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
 280 
 281         if (title == NULL || env->GetStringLength(title)==0) {
 282             title = JNU_NewStringPlatform(env, L" ");
 283             if (title == NULL) {
 284                 throw std::bad_alloc();
 285             }
 286         }
 287 
 288         JavaStringBuffer titleBuffer(env, title);




 242 {
 243     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 244     jobject peer;
 245     LPTSTR fileBuffer = NULL;
 246     LPTSTR currentDirectory = NULL;
 247     jint mode = 0;
 248     BOOL result = FALSE;
 249     DWORD dlgerr;
 250     jstring directory = NULL;
 251     jstring title = NULL;
 252     jstring file = NULL;
 253     jobject fileFilter = NULL;
 254     jobject target = NULL;
 255     jobject parent = NULL;
 256     AwtComponent* awtParent = NULL;
 257     jboolean multipleMode = JNI_FALSE;
 258 
 259     OPENFILENAME ofn;
 260     memset(&ofn, 0, sizeof(ofn));
 261 
 262     peer = (jobject)p;






 263 
 264     try {
 265         DASSERT(peer);
 266         target = env->GetObjectField(peer, AwtObject::targetID);
 267         parent = env->GetObjectField(peer, AwtFileDialog::parentID);
 268         if (parent != NULL) {
 269             awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
 270         }
 271 //      DASSERT(awtParent);
 272         title = (jstring)(env)->GetObjectField(target, AwtDialog::titleID);
 273         HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL;
 274 
 275         if (title == NULL || env->GetStringLength(title)==0) {
 276             title = JNU_NewStringPlatform(env, L" ");
 277             if (title == NULL) {
 278                 throw std::bad_alloc();
 279             }
 280         }
 281 
 282         JavaStringBuffer titleBuffer(env, title);


< prev index next >