Fix segfault. Remove debug output. Change UI Layout.w
authorRuediger Gad <rgad@fb2.fh-frankfurt.de>
Thu, 12 Apr 2012 07:41:19 +0000 (09:41 +0200)
committerRuediger Gad <rgad@fb2.fh-frankfurt.de>
Thu, 12 Apr 2012 07:41:19 +0000 (09:41 +0200)
btconnector.h
qml/QZeeControl/MainPage.qml

index 3b78c74..65c9ce8 100644 (file)
@@ -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));
         }
     }
index 116d223..aeb5599 100644 (file)
@@ -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()
+            }
         }
     }