bool KstIfaceImpl::changeDataFile(const QString& vector, const QString& fileName, bool update) { KST::vectorList.lock().readLock(); KstRVectorPtr rvp = kst_cast<KstRVector>(*KST::vectorList.findTag(vector)); KST::vectorList.lock().unlock(); if (!rvp) { return false; } KST::dataSourceList.lock().writeLock(); KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(fileName); KstDataSourcePtr file; QString invalidSources; if (it == KST::dataSourceList.end()) { file = KstDataSource::loadSource(fileName); if (!file || !file->isValid() || file->isEmpty()) { KST::dataSourceList.lock().unlock(); return false; } KST::dataSourceList.append(file); } else { file = *it; } KST::dataSourceList.lock().unlock(); rvp->writeLock(); file->writeLock(); if (!file->isValidField(vector)) { file->unlock(); rvp->unlock(); return false; } rvp->changeFile(file); file->unlock(); bool rc = rvp->isValid(); rvp->unlock(); if (update) { KstApp::inst()->forceUpdate(); } return rc; }
KJS::Value KstBindDataVector::valid(KJS::ExecState *exec) const { Q_UNUSED(exec) KstRVectorPtr v = makeDataVector(_d); KstReadLocker rl(v); return KJS::Boolean(v->isValid()); }