From aec33552bc3ce13691f100f569a7f9426b13e2d5 Mon Sep 17 00:00:00 2001 From: roangel <roangel@student.ethz.ch> Date: Mon, 14 Aug 2017 18:01:15 +0200 Subject: [PATCH] different tries to fix the crash, apparently removing tabs is creating this crash --- .../GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp | 78 +++++++++++++++++++ pps_ws/src/d_fall_pps/param/Crazyflie.db | 3 +- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp index 49e4b00e..71898e08 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp @@ -63,8 +63,13 @@ int MainGUIWindow::getTabIndexFromName(QString name) void MainGUIWindow::doNumCrazyFlyZonesChanged(int n) { + // FIXME: when we load CF Zones from database, more than one at a time. Change way of updating tabs! + // Maybe remove everything and create new ones always? + + // tabs number management, maybe do it in a different way so we dont have to remove and add everything? // first check if size of tabs is greater than size of vector or viceversa. Have we removed or added a zone? + qDebug("tabWidgetCount : %d", ui->tabWidget->count()); if(ui->tabWidget->count() > scene->crazyfly_zones.size()) { @@ -98,6 +103,77 @@ void MainGUIWindow::doNumCrazyFlyZonesChanged(int n) ui->tabWidget->insertTab(n, widget, qstr); connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int))); } + + // for(int ind = 0; ind < ui->tabWidget->count(); ind++) + // { + // QString qstr = "CrazyFly "; + // qstr.append(QString::number(ind+1)); + // int found_index = getTabIndexFromName(qstr); + + // if(found_index != -1) + // { + // ui->tabWidget->removeTab(found_index); + // } + + // if(cf_linker->isCFZoneLinked(ind)) + // { + // cf_linker->unlink_cf_zone(ind); + // } + // } + +// else +// { +// for(int i = 0; i < ui->tabWidget->count(); i++) +// { +// int CF_index = scene->crazyfly_zones[i]->getIndex(); +// QString qstr = "CrazyFly "; +// qstr.append(QString::number(CF_index + 1)); + +// int found_index = getTabIndexFromName(qstr); +// if(found_index != -1) +// { +// ui->tabWidget->removeTab(found_index); +// } + +// // now unlink it from table also: +// #ifdef CATKIN_MAKE +// if(cf_linker->isCFZoneLinked(n)) +// { +// cf_linker->unlink_cf_zone(n); +// } +// #endif +// // ROS_INFO("inside first for loop"); + +// // ui->tabWidget->removeTab(i); +// // ROS_INFO("removed tab"); + +// // delete ui->tabWidget->widget(i); +// // ROS_INFO("deleted widget"); +// } +// } + + + // while(ui->tabWidget->count() > 0) + // { + // ui->tabWidget->removeTab(0); + // } + + // unlink all? + // cf_linker->clear_all_links(); + + // for(int i = 0; i < scene->crazyfly_zones.size(); i++) + // { + // ROS_INFO("inside for loop"); + // QString qstr = "CrazyFly "; + // int CF_index = scene->crazyfly_zones[i]->getIndex(); + // qstr.append(QString::number(CF_index + 1)); + // crazyFlyZoneTab* widget = new crazyFlyZoneTab(CF_index); + // ui->tabWidget->insertTab(CF_index, widget, qstr); + // // ui->tabWidget->addTab(widget, qstr); + // ROS_INFO("Added tab"); + // connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int))); + // } + // for (int i = 0; i < n; i++) // { // QString qstr = "CrazyFly "; @@ -836,6 +912,7 @@ int MainGUIWindow::read_database_from_file(CrazyflieDB &read_db) void MainGUIWindow::on_load_from_DB_button_clicked() { CrazyflieDB tmp_db; + if(read_database_from_file(tmp_db) == 0) { ROS_INFO_STREAM("database:\n" << tmp_db); @@ -853,6 +930,7 @@ void MainGUIWindow::on_load_from_DB_button_clicked() std::string cf_name = m_data_base.crazyflieEntries[i].crazyflieContext.crazyflieName; std::string radio_address = m_data_base.crazyflieEntries[i].crazyflieContext.crazyflieAddress; int cf_zone_index = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.crazyfly_zone_index; + // we should first create the cf zones that are in the database? bool cf_zone_exists; qreal width = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmax - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmin; diff --git a/pps_ws/src/d_fall_pps/param/Crazyflie.db b/pps_ws/src/d_fall_pps/param/Crazyflie.db index 537875bc..e3e6cbcb 100644 --- a/pps_ws/src/d_fall_pps/param/Crazyflie.db +++ b/pps_ws/src/d_fall_pps/param/Crazyflie.db @@ -1 +1,2 @@ -1,CF2,123,0,0.04,0.24,-0.2,1.14,1.81,2 +1,CF1,123,0,0.65,-0.22,-0.2,5.04,2.02,2 +2,CF2,1234,1,3.26,-2.78,-0.2,7.3,-1.65,2 -- GitLab