H
H
Hider9982016-07-25 14:18:56
Qt
Hider998, 2016-07-25 14:18:56

Why does QML crash when the timer starts?

To poll the modem, a timer is used on the QML side. Every 30ms, it sends a request to the SerialPort special class and writes the response to the console.
QML Code

Timer {
        id: timer1
        interval: 30
        repeat: true
        running: false

        onTriggered: {
            consile.append(sePort.readDataPort());
        }
    }
...
   ToolButton {
            id: callBt
            x: 10
            y: 0
            width: 50
            height: 50
            text: "Connect"
            Layout.rowSpan: 1
            Layout.fillWidth: false
            Layout.fillHeight: true
            transformOrigin: Item.Center
            antialiasing: false
            smooth: false
            scale: 1
            tooltip: "Connect"
            iconSource: "images/connect.png"
            iconName: "connect.png"
            visible: true
            anchors.verticalCenterOffset: 0
            anchors.verticalCenter: parent.verticalCenter
            action: Action{
                shortcut: "Ctrl + F5"
                onTriggered: {
                    sePort.openPort();
                    if(sePort.stance() === true){
                        timer1.start();    // Скорее всего ошибка именно здесь, если убрать эту строчку остальное работает.
                        consile.append("Соединение установлено");
                        stance.text = "Соединение: Подключено"
                        stance.color = "Green"
                    } else {
                        consile.append("Ошибка соединения");
                        stance.text = "Соединение: Не соединено"
                        stance.color = "Black"
                    }
                }
            }
        }
ToolButton {
            id: discallBt
            x: 70
            width: 50
            height: 50
            text: "Disconnect"
            iconSource: "images/disconnect.png"
            tooltip: "Disconnect"
            Layout.fillHeight: true
            action: Action{
                shortcut: "Ctrl + F5"
                onTriggered: {
                    sePort.closePort();
                    if (sePort.stance() !== true){
                        <b>timer1.stop();</b>
                        stance.text = "Соединение: Не соединено"
                        stance.color = "Black"
                    }
                    consile.text = "";
                }
            }
        }

When the callBt button is pressed, the program crashes without explanation.
Shows Segmentation Fault when debugging.
I can't figure out what's wrong. Tell me plz. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2016-07-25
@PavelK

How do you pass an object to QML?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question