@@ -30,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) :
3030 connect (Receiver, SIGNAL (lineReceived (QString)),this , SLOT (processReceivedData (QString)));
3131 connect (Receiver, SIGNAL (lineReceived (QString)),this ->bot , SLOT (processAnswer (QString)));
3232
33+ connect (bot->port , SIGNAL (error (QSerialPort::SerialPortError)),this ,SLOT (handle_port_error (QSerialPort::SerialPortError)));
34+
3335 initUI ();
3436 initSateMachine ();
3537
@@ -44,7 +46,6 @@ MainWindow::MainWindow(QWidget *parent) :
4446 setWindowTitle (" Spherebot Controll" );
4547
4648 qDebug ()<<" mainwindow initialised: " ;
47- connect (restartLayerMsgBox,SIGNAL (accepted ()),this ,SLOT (hey ()));
4849}
4950
5051void MainWindow::fitgraphicsView () // //function to trigger the fitIn function for the graphics view. Actually this shouldn´t be necessary!
@@ -266,6 +267,7 @@ void MainWindow::initSateMachine()
266267 // ///////////////////////////////////////////////// Transitions
267268
268269 connected->addTransition (ui->connectButton , SIGNAL (clicked ()),disconnected);
270+ connected->addTransition (this ,SIGNAL (force_disconnect ()),disconnected);
269271 disconnected->addTransition (ui->connectButton , SIGNAL (clicked ()),try_connect);
270272 try_connect->addTransition (this , SIGNAL (successfully_connected ()),connected);
271273 try_connect->addTransition (this , SIGNAL (not_successfully_connected ()),disconnected);
@@ -372,6 +374,15 @@ MainWindow::~MainWindow()
372374 SaveSettings ();
373375 delete ui;
374376}
377+
378+ void MainWindow::handle_port_error (QSerialPort::SerialPortError err)
379+ {
380+ if (err != QSerialPort::NoError)
381+ {
382+ emit force_disconnect ();
383+ resetPortList ();
384+ }
385+ }
375386// /////////////////////////////////////////////////////////////////////////////
376387
377388bool MainWindow::LoadSettings ()
0 commit comments