/* * Note this is NOT thread-safe, lockSources() should be called around any calls * to this. */ void gravManager::moveToTop( std::vector<RectangleBase*>::iterator i, bool checkGrouping ) { RectangleBase* temp = (*i); RectangleBase* orig = temp; // find highest group in the chain, to move up group members from the top // of the chain while ( checkGrouping && temp->isGrouped() ) temp = temp->getGroup(); // do this to properly find iterator position, since i != temp now if ( temp != orig ) moveToTop( temp, checkGrouping ); else { drawnObjects->erase( i ); drawnObjects->push_back( temp ); if ( temp->isGroup() ) { Group* g = (Group*)temp; for ( int i = 0; i < g->numObjects(); i++ ) moveToTop( (*g)[i], false ); } } }
void gravManager::deleteSource( std::vector<VideoSource*>::iterator si ) { lockSources(); RectangleBase* temp = (RectangleBase*)(*si); VideoSource* s = *si; removeFromLists( temp ); sources->erase( si ); // TODO need case for runway grouping? if ( temp->isGrouped() ) { Group* g = temp->getGroup(); // remove object from the group, regardless of whether it's a siteID // group or not. // this should work for runways, but should be more generic, ie for // groups of groups? maybe in removefromlists, but careful not to // degroup object before it hits that siteID check above or siteIDgroups // will have invalid references g->remove( temp ); // delete the group the object was in if this is the last object in it // and it's an automatically made siteID group // TODO probably have a better metric for determining auto-siteID groups if ( g->getSiteID().compare( "" ) != 0 && g->numObjects() == 0 ) { // note this duplicates the deleteGroup function since that does // mutex locking itself, and we already did that here removeFromLists( (RectangleBase*)g ); // remove the group from the list of siteIDgroups std::map<std::string,Group*>::iterator gi = siteIDGroups->find( g->getSiteID() ); siteIDGroups->erase( gi ); // put off the group delete, since removing it from the tree has to // happen on the main thread, and can't delete it before we remove // it from the tree objectsToDelete->push_back( g ); } } if ( gridAuto ) { std::map<std::string, std::vector<RectangleBase*> > data = std::map<std::string, std::vector<RectangleBase*> >(); data["objects"] = getMovableObjects(); layouts->arrange("grid", getScreenRect(), getEarthRect(), data); } // we need to do videosource's delete somewhere else, since this function // might be on a second thread, which would crash since the videosource // delete needs to do a GL call to delete its texture and GL calls can only // be on the main thread objectsToDelete->push_back( s ); unlockSources(); }