From: Reino Ruusu Date: Wed, 1 Feb 2017 16:02:35 +0000 (+0200) Subject: Fixed merge errors. X-Git-Tag: v1.31.0~5 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fpython.git;a=commitdiff_plain;h=99a7e38e79e1f1bd4a01f37eaa9ea08ae7a9d433 Fixed merge errors. Change-Id: Ia2c8157c0f81c7b77033a5a2477a4671fcb3ac3f --- diff --git a/org.simantics.pythonlink.win32.x86_64/jnipython.dll b/org.simantics.pythonlink.win32.x86_64/jnipython.dll index 44ca25d..e533946 100644 Binary files a/org.simantics.pythonlink.win32.x86_64/jnipython.dll and b/org.simantics.pythonlink.win32.x86_64/jnipython.dll differ diff --git a/org.simantics.pythonlink.win32.x86_64/src/sclpy.c b/org.simantics.pythonlink.win32.x86_64/src/sclpy.c index 4881cc7..686221e 100644 --- a/org.simantics.pythonlink.win32.x86_64/src/sclpy.c +++ b/org.simantics.pythonlink.win32.x86_64/src/sclpy.c @@ -115,6 +115,7 @@ JNIEXPORT jlong JNICALL Java_org_simantics_pythonlink_PythonContext_createContex PyDict_SetItemString(dict, "__builtin__", builtin); PyDict_SetItemString(dict, "__builtins__", builtin); + PyEval_SaveThread(); return (jlong)modDef; } } @@ -856,9 +857,10 @@ jobject pythonDictionaryAsMap(JNIEnv *env, PyObject *dict) { ##VariableImpl( \ JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName, \ jtype value) { \ - PyObject *module = getModule(contextID); \ + PyObject *module; \ \ PyEval_RestoreThread(main_ts); \ + module = getModule(contextID); \ setPythonVariable(module, getPythonString(env, variableName), \ j2py(env, value)); \ PyEval_SaveThread(); \ @@ -883,8 +885,6 @@ JNIEXPORT void JNICALL Java_org_simantics_pythonlink_PythonContext_setPythonNDArrayVariableImpl( JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName, jobject value) { - PyObject *module = getModule(contextID); - if (!hasNumpy) { throwPythonException(env, "Importing numpy failed"); return; @@ -892,6 +892,7 @@ Java_org_simantics_pythonlink_PythonContext_setPythonNDArrayVariableImpl( PyEval_RestoreThread(main_ts); { + PyObject *module = getModule(contextID); PyObject *pythonName = getPythonString(env, variableName); PyObject *val = getPythonNDArray(env, value); @@ -904,9 +905,10 @@ JNIEXPORT void JNICALL Java_org_simantics_pythonlink_PythonContext_setPythonVariantVariableImpl( JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName, jobject value, jobject binding) { - PyObject *module = getModule(contextID); + PyObject *module; PyEval_RestoreThread(main_ts); + module = getModule(contextID); setPythonVariable(module, getPythonString(env, variableName), getPythonObject(env, value, binding)); PyEval_SaveThread(); @@ -915,13 +917,13 @@ Java_org_simantics_pythonlink_PythonContext_setPythonVariantVariableImpl( JNIEXPORT jint JNICALL Java_org_simantics_pythonlink_PythonContext_executePythonStatementImpl( JNIEnv *env, jobject thisObj, jlong contextID, jstring statement) { - PyObject *module = getModule(contextID); - const char *utfchars = (*env)->GetStringUTFChars(env, statement, NULL); PyEval_RestoreThread(main_ts); PyErr_Clear(); { + PyObject *module = getModule(contextID); + jclass sclReportingWriterClass = (*env)->FindClass(env, SCL_REPORTING_WRITER_CLASS); jmethodID constructor = (*env)->GetMethodID(env, sclReportingWriterClass, "", "()V"); jmethodID flushMethod = (*env)->GetMethodID(env, sclReportingWriterClass, "flush", "()V");