diff options
author | Sven Gothel <[email protected]> | 2012-07-05 14:32:00 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-07-05 14:32:00 +0200 |
commit | fd06292d4a208cbd613f4bdce7cae12e075e70ec (patch) | |
tree | 75bf50a19e631c22f575f516248c5681dab3eda9 /src/newt/native/NewtCommon.c | |
parent | 9b35c57425b0a5f6b789b9b43a62a8b64be51d86 (diff) |
NativeWindow/Newt X11ErrorHandler enhancement / unification - don't throw exceptions. Handles also XAWT BadMatch X_SetInputFocus.
X11ErrorHandler code now dumps proper information about the opcode and error message and the running Java thread.
Having propery "nativewindow.debug.X11Util.XErrorStackDump" or "nativewindow.debug=all' set,
a stack trace is dumped.
Since the X11ErrorHandler may catch an XAWT error: BadMatch X_SetInputFocus,
we cannot throw an exception and better keep running.
Diffstat (limited to 'src/newt/native/NewtCommon.c')
-rw-r--r-- | src/newt/native/NewtCommon.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c index 3713cfd6c..7f070e7d3 100644 --- a/src/newt/native/NewtCommon.c +++ b/src/newt/native/NewtCommon.c @@ -1,5 +1,6 @@ #include "NewtCommon.h" +#include <string.h> static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; @@ -43,6 +44,24 @@ void NewtCommon_init(JNIEnv *env) { } } +const char * NewtCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText) { + if(NULL != jniEnv && NULL != clazz && NULL != jGetStrID) { + jstring jstr = (jstring) (*jniEnv)->CallStaticObjectMethod(jniEnv, clazz, jGetStrID); + if(NULL != jstr) { + const char * str = (*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL); + if( NULL != str) { + strncpy(dest, str, destSize-1); + dest[destSize-1] = 0; // EOS + (*jniEnv)->ReleaseStringUTFChars(jniEnv, jstr, str); + return dest; + } + } + } + strncpy(dest, altText, destSize-1); + dest[destSize-1] = 0; // EOS + return dest; +} + jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str) { jchar* strChars = NULL; |