jdk/src/solaris/native/sun/awt/awt_InputMethod.c
changeset 24130 db72fc72f87b
parent 18135 d9be76f1a19c
equal deleted inserted replaced
23699:fa664c1f28c1 24130:db72fc72f87b
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   317      */
   317      */
   318     if (X11im == NULL && pX11IMData != NULL) {
   318     if (X11im == NULL && pX11IMData != NULL) {
   319         JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
   319         JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
   320                              "flushText",
   320                              "flushText",
   321                              "()V");
   321                              "()V");
       
   322         JNU_CHECK_EXCEPTION_RETURN(env, NULL);
   322         /* IMPORTANT:
   323         /* IMPORTANT:
   323            The order of the following calls is critical since "imInstance" may
   324            The order of the following calls is critical since "imInstance" may
   324            point to the global reference itself, if "freeX11InputMethodData" is called
   325            point to the global reference itself, if "freeX11InputMethodData" is called
   325            first, the global reference will be destroyed and "setX11InputMethodData"
   326            first, the global reference will be destroyed and "setX11InputMethodData"
   326            will in fact fail silently. So pX11IMData will not be set to NULL.
   327            will in fact fail silently. So pX11IMData will not be set to NULL.
  1118 
  1119 
  1119     if ((text = pre_draw->text) != NULL) {
  1120     if ((text = pre_draw->text) != NULL) {
  1120         if (text->string.multi_byte != NULL) {
  1121         if (text->string.multi_byte != NULL) {
  1121             if (pre_draw->text->encoding_is_wchar == False) {
  1122             if (pre_draw->text->encoding_is_wchar == False) {
  1122                 javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
  1123                 javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
       
  1124                 if (javastr == NULL) {
       
  1125                     goto finally;
       
  1126                 }
  1123             } else {
  1127             } else {
  1124                 char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
  1128                 char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
  1125                 if (mbstr == NULL) {
  1129                 if (mbstr == NULL) {
  1126                     goto finally;
  1130                     goto finally;
  1127                 }
  1131                 }
  1128                 javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
  1132                 javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
  1129                 free(mbstr);
  1133                 free(mbstr);
       
  1134                 if (javastr == NULL) {
       
  1135                     goto finally;
       
  1136                 }
  1130             }
  1137             }
  1131         }
  1138         }
  1132         if (text->feedback != NULL) {
  1139         if (text->feedback != NULL) {
  1133             int cnt;
  1140             int cnt;
  1134             jint *tmpstyle;
  1141             jint *tmpstyle;
  1135 
  1142 
  1136             style = (*env)->NewIntArray(env, text->length);
  1143             style = (*env)->NewIntArray(env, text->length);
  1137             if (JNU_IsNull(env, style)) {
  1144             if (JNU_IsNull(env, style)) {
       
  1145                 (*env)->ExceptionClear(env);
  1138                 THROW_OUT_OF_MEMORY_ERROR();
  1146                 THROW_OUT_OF_MEMORY_ERROR();
  1139                 goto finally;
  1147                 goto finally;
  1140             }
  1148             }
  1141 
  1149 
  1142             if (sizeof(XIMFeedback) == sizeof(jint)) {
  1150             if (sizeof(XIMFeedback) == sizeof(jint)) {
  1393 #endif /* __linux__ || MACOSX */
  1401 #endif /* __linux__ || MACOSX */
  1394 
  1402 
  1395     pX11IMData->lookup_buf = 0;
  1403     pX11IMData->lookup_buf = 0;
  1396     pX11IMData->lookup_buf_len = 0;
  1404     pX11IMData->lookup_buf_len = 0;
  1397 
  1405 
  1398     if (createXIC(env, pX11IMData, (Window)window)
  1406     if (createXIC(env, pX11IMData, (Window)window) == False) {
  1399         == False) {
       
  1400         destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
  1407         destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
  1401         pX11IMData = (X11InputMethodData *) NULL;
  1408         pX11IMData = (X11InputMethodData *) NULL;
       
  1409         if ((*env)->ExceptionCheck(env)) {
       
  1410             goto finally;
       
  1411         }
  1402     }
  1412     }
  1403 
  1413 
  1404     setX11InputMethodData(env, this, pX11IMData);
  1414     setX11InputMethodData(env, this, pX11IMData);
  1405 
  1415 
       
  1416 finally:
  1406     AWT_UNLOCK();
  1417     AWT_UNLOCK();
  1407     return (pX11IMData != NULL);
  1418     return (pX11IMData != NULL);
  1408 }
  1419 }
  1409 
  1420 
  1410 JNIEXPORT void JNICALL
  1421 JNIEXPORT void JNICALL