thp / pyotherside

Python Bindings for Qt 5 and Qt 6. Allows you to access a CPython 3 interpreter directly from your Qt QML user interface code.
https://thp.io/2011/pyotherside/
Other
364 stars 49 forks source link

Segfault when trying to call a function. #67

Open MRZA-MRZA opened 8 years ago

MRZA-MRZA commented 8 years ago

I made a simple app for SailfishOS using pyotherside and it worked, but then I tried to run (after writing new qml) it on desktop (Linux) it crashed. So I wrote test code that also crashed. My QML code:

import QtQuick 2.3
import QtQuick.Window 2.2
import io.thp.pyotherside 1.4
import QtQuick.Controls 1.4

Window{
    visible: true

    Button{
        id: button
        text: "Test"
        onClicked:{
            python.test();
        }
    }

    Python{
            id: python
            onError: console.log('Error: ' + traceback)
            onReceived: console.log('Event: ' + data)
            Component.onCompleted:{
                addImportPath(Qt.resolvedUrl("."));
                importModule("mytest", function(){});
            }

            function test(){
                call("mytest.testFunc", function(){})
            }
    }
}

Python code:

import pyotherside

def testFunc():
    pyotherside.send("testevent", "test")

When I press the button application crashes. Tested on Ubuntu 16.04 and Debian. Here is full sources for Qt Creator https://www.dropbox.com/s/3kq5wolaqtxxb4n/TestApp.tar.xz?dl=0 Python 3.5.1+ Qt 5.5.1