]> gerrit.simantics Code Review - simantics/python.git/commitdiff
Fixed merge errors. 17/317/1
authorReino Ruusu <reino.ruusu@vtt.fi>
Wed, 1 Feb 2017 16:02:35 +0000 (18:02 +0200)
committerReino Ruusu <reino.ruusu@vtt.fi>
Wed, 1 Feb 2017 16:02:35 +0000 (18:02 +0200)
Change-Id: Ia2c8157c0f81c7b77033a5a2477a4671fcb3ac3f

org.simantics.pythonlink.win32.x86_64/jnipython.dll
org.simantics.pythonlink.win32.x86_64/src/sclpy.c

index 44ca25da907bb65226e81e87ad169b88cd10dcdf..e5339466a7dc2c6854d07f4d9b6f02b02425d111 100644 (file)
Binary files a/org.simantics.pythonlink.win32.x86_64/jnipython.dll and b/org.simantics.pythonlink.win32.x86_64/jnipython.dll differ
index 4881cc7d7c26d4a20979542530230724dc1df5f2..686221e2ac09da96874dc03c7c5abb857495b2e2 100644 (file)
@@ -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, "<init>", "()V");
                jmethodID flushMethod = (*env)->GetMethodID(env, sclReportingWriterClass, "flush", "()V");