// 关闭特定的demux filter void CloseGMapDemuxFilter_Lock(map<HANDLE,RegIDPID>& map_hFilter_ReqIDPID,CDCA_U8 byReqID, CDCA_U16 wPid, MutexT & mutex) { HANDLE handle = 0; { AutoLockT lockIt(mutex); map<HANDLE,RegIDPID>::iterator it; for(it=map_hFilter_ReqIDPID.begin(); it!=map_hFilter_ReqIDPID.end();it++) { if(it->second.byReqID == byReqID && it->second.wPid == wPid) { dxreport("delete filter, byReqID:%d wPid:0x%x\n", byReqID, wPid); //tsdemux_delSectionFilter(it->first,NULL); handle = it->first; map_hFilter_ReqIDPID.erase(it); break; } } } if(handle!=0) { tsdemux_delSectionFilter(handle,NULL); } }
NS_IMETHODIMP nsTextEditRules::BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection) { if (mLockRulesSniffing) return NS_OK; nsAutoLockRulesSniffing lockIt(this); mDidExplicitlySetInterline = PR_FALSE; if (!mActionNesting) { // let rules remember the top level action mTheAction = action; } mActionNesting++; // get the selection and cache the position before editing nsCOMPtr<nsISelection> selection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); NS_ENSURE_SUCCESS(res, res); selection->GetAnchorNode(getter_AddRefs(mCachedSelectionNode)); selection->GetAnchorOffset(&mCachedSelectionOffset); return NS_OK; }
void ChunkCache::setChunk(PositionI chunkBasePosition, const std::vector<std::uint8_t> &buffer) { getDebugLog() << "stored chunk at " << chunkBasePosition << " with buffer of length " << buffer.size() << postnl; std::unique_lock<std::mutex> lockIt(theLock); static_assert(NullChunk == std::size_t(), "invalid value for NullChunk"); std::size_t &startingChunkIndex = startingChunksMap[chunkBasePosition]; std::size_t prevChunkIndex = NullChunk; std::size_t bufferPos = 0; while(bufferPos < buffer.size()) { std::size_t chunkIndex; if(prevChunkIndex == NullChunk) chunkIndex = startingChunkIndex; else chunkIndex = fileChunks[prevChunkIndex].nextChunk; if(chunkIndex == NullChunk) { chunkIndex = allocChunk(); if(prevChunkIndex == NullChunk) startingChunkIndex = chunkIndex; else fileChunks[prevChunkIndex].nextChunk = chunkIndex; } prevChunkIndex = chunkIndex; std::size_t currentChunkSize = chunkSize; if(currentChunkSize > buffer.size() - bufferPos) currentChunkSize = buffer.size() - bufferPos; fileChunks[chunkIndex].usedSize = currentChunkSize; bufferPos += currentChunkSize; } std::size_t freeChunkIndex; if(prevChunkIndex == NullChunk) { freeChunkIndex = startingChunkIndex; startingChunkIndex = NullChunk; } else { freeChunkIndex = fileChunks[prevChunkIndex].nextChunk; fileChunks[prevChunkIndex].nextChunk = NullChunk; } while(freeChunkIndex != NullChunk) { std::size_t nextChunkIndex = fileChunks[freeChunkIndex].nextChunk; freeChunk(freeChunkIndex); freeChunkIndex = nextChunkIndex; } bufferPos = 0; std::size_t chunkIndex = startingChunkIndex; while(bufferPos < buffer.size()) { assert(chunkIndex != NullChunk); std::size_t currentChunkSize = chunkSize; if(currentChunkSize > buffer.size() - bufferPos) currentChunkSize = buffer.size() - bufferPos; fileChunks[chunkIndex].usedSize = currentChunkSize; try { static_assert(NullChunk == 0, "invalid value for NullChunk"); std::int64_t filePosition = static_cast<std::int64_t>(chunkIndex - 1) * chunkSize; // skip null chunk writer->seek(filePosition, stream::SeekPosition::Start); writer->writeBytes(&buffer[bufferPos], currentChunkSize); } catch(stream::IOException &e) { try { writer->flush(); } catch(stream::IOException &) { } throw e; } bufferPos += currentChunkSize; chunkIndex = fileChunks[chunkIndex].nextChunk; } assert(chunkIndex == NullChunk); writer->flush(); }
bool ChunkCache::hasChunk(PositionI chunkBasePosition) { std::unique_lock<std::mutex> lockIt(theLock); return startingChunksMap.count(chunkBasePosition) != 0; }
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name) : UBDockPaletteWidget(parent) , imageGatherer(NULL) { setObjectName(name); mName = "FeaturesWidget"; mVisibleState = true; SET_STYLE_SHEET(); mIconToLeft = QPixmap(":images/library_open.png"); mIconToRight = QPixmap(":images/library_close.png"); setAcceptDrops(true); //Main UBFeature functionality controller = new UBFeaturesController(this); //Main layout including all the widgets in palette layout = new QVBoxLayout(this); //Path icon view on the top of the palette pathListView = new UBFeaturesListView(this, objNamePathList); controller->assignPathListView(pathListView); centralWidget = new UBFeaturesCentralWidget(this); controller->assignFeaturesListView(centralWidget->listView()); centralWidget->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt()); //Bottom actionbar for DnD, quick search etc mActionBar = new UBFeaturesActionBar(controller, this); //Filling main layout layout->addWidget(pathListView); layout->addWidget(centralWidget); layout->addWidget(mActionBar); connect(centralWidget->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &))); connect(this, SIGNAL(sendFileNameList(QStringList)), centralWidget, SIGNAL(sendFileNameList(QStringList))); connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &))); connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder())); connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *))); connect(mActionBar, SIGNAL(deleteSelectedElements()), this, SLOT(deleteSelectedElements())); connect(mActionBar, SIGNAL(addToFavorite(const UBFeaturesMimeData *)), this, SLOT(addToFavorite(const UBFeaturesMimeData *))); connect(mActionBar, SIGNAL(removeFromFavorite(const UBFeaturesMimeData *)), this, SLOT(removeFromFavorite(const UBFeaturesMimeData *))); connect(mActionBar, SIGNAL(addElementsToFavorite() ), this, SLOT ( addElementsToFavorite()) ); connect(mActionBar, SIGNAL(removeElementsFromFavorite()), this, SLOT (removeElementsFromFavorite())); connect(mActionBar, SIGNAL(rescanModel()), this, SLOT(rescanModel())); connect(pathListView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &))); connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>))); connect(UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray, QString)) , this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray, QString))); connect(centralWidget, SIGNAL(lockMainWidget(bool)), this, SLOT(lockIt(bool))); connect(centralWidget, SIGNAL(createNewFolderSignal(QString)), controller, SLOT(addNewFolder(QString))); connect(controller, SIGNAL(scanStarted()), centralWidget, SLOT(scanStarted())); connect(controller, SIGNAL(scanFinished()), centralWidget, SLOT(scanFinished())); connect(controller, SIGNAL(scanStarted()), mActionBar, SLOT(lockIt())); connect(controller, SIGNAL(scanFinished()), mActionBar, SLOT(unlockIt())); connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int))); connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SIGNAL(increaseStatusBarValue())); connect(controller, SIGNAL(scanCategory(QString)), centralWidget, SIGNAL(scanCategory(QString))); connect(controller, SIGNAL(scanPath(QString)), centralWidget, SIGNAL(scanPath(QString))); }