diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h index 2418484d7c33e03794471c2bb48bf0394380e500..c9691a581b7cc6297e574c70467b4833c7fb881b 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h @@ -45,7 +45,7 @@ public: void removeTable(); public slots: - void removeCrazyFlyZone(int index); + void removeCrazyFlyZone(int cf_zone_index); void setSelectedCrazyFlyZone(int index); void changeModeTo(int next_mode); 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 601d24db86c5523edf075340716783e02ce3e2b4..138331a3e084a2775ac82861c876dd7a012724b5 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 @@ -186,8 +186,8 @@ void MainGUIWindow::_init() void MainGUIWindow::doTabClosed(int tab_index) { QString name = ui->tabWidget->tabText(tab_index); - int cf_index = cf_linker->getCFZoneIndexFromName(name); - scene->removeCrazyFlyZone(cf_index); + int cf_zone_index = cf_linker->getCFZoneIndexFromName(name); + scene->removeCrazyFlyZone(cf_zone_index); } void MainGUIWindow::setTabIndex(int index) diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp index 4cf079ff972d812fd4453e913e203ef3d1e38535..f38f87226c3f2e32aa16d1eed5b91fc06e95df81 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp @@ -321,13 +321,19 @@ QRectF myGraphicsScene::getRectFCrazyFlyZone(int index) return rect; } -void myGraphicsScene::removeCrazyFlyZone(int index) +void myGraphicsScene::removeCrazyFlyZone(int cf_zone_index) { - int n = crazyfly_zones[index]->getIndex(); - this->removeItem(crazyfly_zones[index]); - crazyfly_zones.erase(crazyfly_zones.begin() + index); - qDebug("removed CFzone %d", index); - emit numCrazyFlyZonesChanged(n); // for tab managing + for(int i = 0; i < crazyfly_zones.size(); i++) + { + if(crazyfly_zones[i]->getIndex() == cf_zone_index) + { + this->removeItem(crazyfly_zones[i]); + crazyfly_zones.erase(crazyfly_zones.begin() + i); + qDebug("removed CFzone %d", cf_zone_index); + emit numCrazyFlyZonesChanged(cf_zone_index); // for tab managing + break; + } + } } void myGraphicsScene::removeTable()