예제 #1
0
bool KST::deleteDependents(KstVectorPtr vectorFor) {
  KST::dataObjectList.lock().readLock();
  KstDataObjectList dol = QDeepCopy<KstDataObjectList>(KST::dataObjectList);
  KST::dataObjectList.lock().readUnlock();
  for (KstDataObjectList::Iterator i = dol.begin(); i != dol.end(); ++i) {
    bool user = (*i)->uses(vectorFor);
    if (user) {
      KstDataObjectPtr dop = *i;
      KST::dataObjectList.lock().writeLock();
      KST::dataObjectList.remove(dop);
      KST::dataObjectList.lock().writeUnlock();
      dop->deleteDependents();
    }
  }

  return true;
}
예제 #2
0
bool KstDataObject::deleteDependents() {
  KstDataObjectList dol;
  KstDataObjectList::iterator i;

  KST::dataObjectList.lock().readLock();
  dol = KST::dataObjectList;
  KST::dataObjectList.lock().unlock();
  
  for (i = dol.begin(); i != dol.end(); ++i) {
    bool user = (*i)->uses(KstObjectPtr(this));
    
    if (!user) {
      for (KstVectorMap::Iterator j = _outputVectors.begin(); !user && j != _outputVectors.end(); ++j) {
        user = (*i)->uses(KstObjectPtr((*j).data()));
      }

      for (KstScalarMap::Iterator j = _outputScalars.begin(); !user && j != _outputScalars.end(); ++j) {
        user = (*i)->uses(KstObjectPtr((*j).data()));
      }

      for (KstStringMap::Iterator j = _outputStrings.begin(); !user && j != _outputStrings.end(); ++j) {
        user = (*i)->uses(KstObjectPtr((*j).data()));
      }
    }

    if (user) {
      KstDataObjectPtr dop = *i;
      
      KST::dataObjectList.lock().writeLock();
      KST::dataObjectList.erase(i);
      KST::dataObjectList.lock().unlock();

      dop->deleteDependents();
    }
  }

  return true;
}