From: Ruediger Gad Date: Thu, 12 Apr 2012 07:41:19 +0000 (+0200) Subject: Fix segfault. Remove debug output. Change UI Layout.w X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=56cdfc783c6ba97659e6feb5b8e5b954bfd9f9e9;p=qzeecontrol Fix segfault. Remove debug output. Change UI Layout.w --- diff --git a/btconnector.h b/btconnector.h index 3b78c74..65c9ce8 100644 --- a/btconnector.h +++ b/btconnector.h @@ -29,14 +29,20 @@ class BtConnector : public QObject { Q_OBJECT public: - explicit BtConnector(QObject *parent = 0){qDebug("BtConnector Constructor");} - ~BtConnector(){if(socket != NULL) delete socket;} + explicit BtConnector(QObject *parent = 0){ + + } + ~BtConnector(){ + if(socket) + delete socket; + } Q_INVOKABLE void connect(QString address, int port){ qDebug("Trying to connect to: %s--%d", address.toUtf8().constData(), port); - if(socket != NULL) + if(socket) delete socket; + socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); QObject::connect(socket, SIGNAL(connected()), this, SIGNAL(connected())); QObject::connect(socket, SIGNAL(disconnected()), this, SIGNAL(disconnected())); @@ -51,13 +57,14 @@ public: public slots: void disconnect(){ - if(socket == NULL) + if(!socket) return; if(socket->isOpen()) socket->close(); delete socket; + socket = 0; } signals: @@ -105,7 +112,7 @@ private slots: } } - qDebug("Button map: %d", buttonMap); +// qDebug("Button map: %d", buttonMap); emit(buttonsChanged(buttonMap & 0x01, buttonMap & 0x02, buttonMap & 0x04, buttonMap & 0x08)); } } diff --git a/qml/QZeeControl/MainPage.qml b/qml/QZeeControl/MainPage.qml index 116d223..aeb5599 100644 --- a/qml/QZeeControl/MainPage.qml +++ b/qml/QZeeControl/MainPage.qml @@ -25,41 +25,36 @@ import qzeecontrol 1.0 Page { tools: commonTools - Label { - id: label - anchors.centerIn: parent - text: "Press to connect." - } - Button{ - id: connectButton - anchors { - horizontalCenter: parent.horizontalCenter - top: label.bottom - topMargin: 10 - } + Column { + anchors.centerIn: parent + spacing: 10 - text: "Connect" + Label { + id: label - onClicked: { - btDiscovery.discovery = true + text: "Press to connect." } - } - Button{ - id: disconnectButton + Button{ + id: connectButton - anchors { - horizontalCenter: parent.horizontalCenter - top: connectButton.bottom - topMargin: 10 + text: "Connect" + + onClicked: { + btDiscovery.discovery = true + } } - text: "Disconnect" + Button{ + id: disconnectButton - onClicked: { - btConn.disconnect() + text: "Disconnect" + + onClicked: { + btConn.disconnect() + } } }