void QGeoTileRequestManagerPrivate::tileFetched(const QGeoTileSpec &spec) { map_->newTileFetched(spec); requested_.remove(spec); retries_.remove(spec); futures_.remove(spec); }
int mythfile_close(int fileID) { int result = -1; LOG(VB_FILE, LOG_DEBUG, LOC + QString("mythfile_close(%1)").arg(fileID)); m_fileWrapperLock.lockForRead(); if (m_ringbuffers.contains(fileID)) { RingBuffer *rb = m_ringbuffers[fileID]; m_ringbuffers.remove(fileID); delete rb; result = 0; } else if (m_remotefiles.contains(fileID)) { RemoteFile *rf = m_remotefiles[fileID]; m_remotefiles.remove(fileID); delete rf; result = 0; } else if (m_localfiles.contains(fileID)) { close(m_localfiles[fileID]); m_localfiles.remove(fileID); result = 0; } m_fileWrapperLock.unlock(); return result; }
bool removeTimer(int id) { if (id >= timerInfos.size()) return false; WinRTTimerInfo &info = timerInfos[id]; if (info.timerId == INVALID_TIMER_ID) return false; if (info.interval > 0 && (!timerIdToHandle.contains(id) || !timerIdToCancelHandle.contains(id))) return false; info.timerId = INVALID_TIMER_ID; // Remove invalid timerinfos from the vector's end, if the timer with the highest id was removed int lastTimer = timerInfos.size() - 1; while (lastTimer >= 0 && timerInfos.at(lastTimer).timerId == INVALID_TIMER_ID) --lastTimer; if (lastTimer >= 0 && lastTimer != timerInfos.size() - 1) timerInfos.resize(lastTimer + 1); timerIdToObject.remove(id); // ... remove handle from all lists if (info.interval > 0) { HANDLE handle = timerIdToHandle.take(id); timerHandleToId.remove(handle); SetEvent(timerIdToCancelHandle.take(id)); } return true; }
static inline QHash<PropertyName, QVariant> getProperties(const ModelNode &node) { QHash<PropertyName, QVariant> propertyHash; if (QmlObjectNode::isValidQmlObjectNode(node)) { foreach (const AbstractProperty &abstractProperty, node.properties()) { if (abstractProperty.isVariantProperty() || (abstractProperty.isBindingProperty() && !abstractProperty.name().contains("anchors."))) propertyHash.insert(abstractProperty.name(), QmlObjectNode(node).instanceValue(abstractProperty.name())); } if (QmlItemNode::isValidQmlItemNode(node)) { QmlItemNode itemNode(node); propertyHash.insert("width", itemNode.instanceValue("width")); propertyHash.insert("height", itemNode.instanceValue("height")); propertyHash.remove("x"); propertyHash.remove("y"); propertyHash.remove("rotation"); propertyHash.remove("opacity"); } } return propertyHash; }
void ObjectHelper::releaseObjectHelper(const Abstract3DRenderer *cacheId, ObjectHelper *&obj) { Q_ASSERT(cacheId); if (obj) { QHash<QString, ObjectHelperRef *> *objectTable = cacheTable.value(cacheId, 0); if (objectTable) { // Delete object if last reference is released ObjectHelperRef *objRef = objectTable->value(obj->m_objectFile, 0); if (objRef) { objRef->refCount--; if (objRef->refCount <= 0) { objectTable->remove(obj->m_objectFile); delete objRef->obj; delete objRef; } } if (objectTable->isEmpty()) { // Remove the entire cache if last object was removed cacheTable.remove(cacheId); delete objectTable; } } else { // Just delete the object if unknown cache delete obj; } obj = 0; } }
BattlePStorage::BattlePStorage(BattlePlugin *p) { for (int i = 0; i < lastEnum; i++) { calls[i] = NULL; } QHash<QString, Hook> functions = p->getHooks(); if (functions.contains("battleStarting(BattleInterface&)")) { calls[battleStarting] = functions.value("battleStarting(BattleInterface&)"); functions.remove("battleStarting(BattleInterface&)"); } if (functions.contains("emitCommand(BattleInterface&,int,int,QByteArray)")) { calls[emitCommand] = functions.value("emitCommand(BattleInterface&,int,int,QByteArray)"); functions.remove("emitCommand(BattleInterface&,int,int,QByteArray)"); } if (!functions.empty()) { /* To Do: Some way to propagate an error about unreckognized stuff, maybe cancel the plugin entirely */ } plugin = p; }
void QGeoTileRequestManagerPrivate::tileFetched(const QGeoTileSpec &spec) { m_map->updateTile(spec); m_requested.remove(spec); m_retries.remove(spec); m_futures.remove(spec); }
void LoggerThread::handleItem(LoggingItem *item) { if (item->type & kRegistering) { int64_t tid = getThreadTid(item); QMutexLocker locker(&logThreadMutex); logThreadHash[item->threadId] = strdup(item->threadName); if (debugRegistration) { snprintf(item->message, LOGLINE_MAX, "Thread 0x%" PREFIX64 "X (%" PREFIX64 "d) registered as \'%s\'", (long long unsigned int)item->threadId, (long long int)tid, logThreadHash[item->threadId]); } } else if (item->type & kDeregistering) { int64_t tid = 0; { QMutexLocker locker(&logThreadTidMutex); if( logThreadTidHash.contains(item->threadId) ) { tid = logThreadTidHash[item->threadId]; logThreadTidHash.remove(item->threadId); } } QMutexLocker locker(&logThreadMutex); if (logThreadHash.contains(item->threadId)) { if (debugRegistration) { snprintf(item->message, LOGLINE_MAX, "Thread 0x%" PREFIX64 "X (%" PREFIX64 "d) deregistered as \'%s\'", (long long unsigned int)item->threadId, (long long int)tid, logThreadHash[item->threadId]); } item->threadName = logThreadHash[item->threadId]; logThreadHash.remove(item->threadId); } } if (item->message[0] != '\0') { QMutexLocker locker(&loggerListMutex); QList<LoggerBase *>::iterator it; for (it = loggerList.begin(); it != loggerList.end(); ++it) (*it)->logmsg(item); } }
QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTiles(const QSet<QGeoTileSpec> &tiles) { QSet<QGeoTileSpec> cancelTiles = requested_ - tiles; QSet<QGeoTileSpec> requestTiles = tiles - requested_; QSet<QGeoTileSpec> cached; // int tileSize = tiles.size(); // int newTiles = requestTiles.size(); typedef QSet<QGeoTileSpec>::const_iterator iter; QList<QSharedPointer<QGeoTileTexture> > cachedTex; QGeoTiledMappingManagerEngine *engine = map_ ? static_cast<QGeoTiledMappingManagerEngine *>(map_->engine()) : 0; // remove tiles in cache from request tiles if (engine) { iter i = requestTiles.constBegin(); iter end = requestTiles.constEnd(); for (; i != end; ++i) { QGeoTileSpec tile = *i; QSharedPointer<QGeoTileTexture> tex = engine->getTileTexture(tile); if (tex) { cachedTex << tex; cached.insert(tile); } } } requestTiles -= cached; requested_ -= cancelTiles; requested_ += requestTiles; // qDebug() << "required # tiles: " << tileSize << ", new tiles: " << newTiles << ", total server requests: " << requested_.size(); if (!requestTiles.isEmpty() || !cancelTiles.isEmpty()) { if (engine) { // qDebug() << "new server requests: " << requestTiles.size() << ", server cancels: " << cancelTiles.size(); engine->updateTileRequests(map_, requestTiles, cancelTiles); // Remove any cancelled tiles from the error retry hash to avoid // re-using the numbers for a totally different request cycle. iter i = cancelTiles.constBegin(); iter end = cancelTiles.constEnd(); for (; i != end; ++i) { retries_.remove(*i); futures_.remove(*i); } } } return cachedTex; }
static void patchANSI(QHash<QString, Key>& map){ map.remove("bslash_iso"); map.remove("hash"); Key& enter = map["enter"]; enter.x = ANSI_ENTER_X; enter.y = ANSI_ENTER_Y; enter.width = ANSI_ENTER_W; enter.height = ANSI_ENTER_H; Key& lshift = map["lshift"]; lshift.x = ANSI_LSHIFT_X; lshift.width = ANSI_LSHIFT_W; }
static void PostLoad(const QString &cacheKey) { m_loadingImagesLock.lock(); m_loadingImages.remove(cacheKey); m_loadingImagesCond.wakeAll(); m_loadingImagesLock.unlock(); }
// Load a theme from a given file void Global::loadThemeFile(QHash<QString,QString> &resourceList, QFile &file, QString themeName) { if (!file.exists()) return; if(!file.open(QIODevice::ReadOnly)) return; QTextStream in(&file); bool themeFound = false; QString themeHeader = "[" + themeName.trimmed() + "]"; while(!in.atEnd()) { QString line = in.readLine(); if (!line.startsWith("#")){ if (line.startsWith("[") && themeHeader != line) themeFound = false; if (line.startsWith("[") && themeHeader == line) themeFound = true; if (themeFound && !line.startsWith("[") && line != "") { QStringList fields = line.split("="); if (fields.size() >= 2) { QString key = fields[0].simplified(); QString value = fields[1].split("#").at(0).simplified(); QFile f(value); if (f.exists()) { resourceList.remove(":"+key); resourceList.insert(":"+key,value); } } } } } file.close(); }
QImage* ResourceManager::getImage(QString path, bool recache) { if (recache && sSourceImageHash.contains(path)) { delete sSourceImageHash[path]; sSourceImageHash.remove(path); } if (!sSourceImageHash.contains(path)) { QString fullPath = getResourcePath(path, ResourceManager::FileType_Image); QFileInfo fileInfo = QFileInfo (fullPath); if (!fileInfo.isFile()) {return NULL;} try { sSourceImageHash.insert(path, new QImage(fullPath)); } catch(char *str) { printf("File:%s couldn't be loaded.", str); return NULL; } }; return sSourceImageHash[path]; }
void VDirectoryTree::updateItemDirectChildren(QTreeWidgetItem *p_item) { QPointer<VDirectory> parentDir; if (p_item) { parentDir = getVDirectory(p_item); } else { parentDir = m_notebook->getRootDir(); } const QVector<VDirectory *> &dirs = parentDir->getSubDirs(); QHash<VDirectory *, QTreeWidgetItem *> itemDirMap; int nrChild = p_item ? p_item->childCount() : topLevelItemCount(); for (int i = 0; i < nrChild; ++i) { QTreeWidgetItem *item = p_item ? p_item->child(i) : topLevelItem(i); itemDirMap.insert(getVDirectory(item), item); } for (int i = 0; i < dirs.size(); ++i) { VDirectory *dir = dirs[i]; QTreeWidgetItem *item = itemDirMap.value(dir, NULL); if (item) { if (p_item) { p_item->removeChild(item); p_item->insertChild(i, item); } else { int topIdx = indexOfTopLevelItem(item); takeTopLevelItem(topIdx); insertTopLevelItem(i, item); } itemDirMap.remove(dir); } else { // Insert a new item if (p_item) { item = new QTreeWidgetItem(p_item); } else { item = new QTreeWidgetItem(this); } fillTreeItem(item, dir); buildSubTree(item, 1); } expandSubTree(item); } // Delete items without corresponding VDirectory for (auto iter = itemDirMap.begin(); iter != itemDirMap.end(); ++iter) { QTreeWidgetItem *item = iter.value(); if (p_item) { p_item->removeChild(item); } else { int topIdx = indexOfTopLevelItem(item); takeTopLevelItem(topIdx); } delete item; } }
static int wrap_gzclose( int fd ) { if ( !gzHandles.contains( fd )) return -1; int result = gzclose( gzHandles[ fd ] ); gzHandles.remove( fd ); return result; }
void Radio_Impl::setGroup(const QString& group) { QString groupName; QWidget *window = this->window(); fGroup = group; if (window) groupName = QString("[%1]/%2").arg(window->objectName()).arg(group); else groupName = QString("[]/%1").arg(group); if (fButtonGroup) { fButtonGroup->removeButton(this); if (fButtonGroup->buttons().size() == 0) { sButtonGroups.remove(fButtonGroup->objectName()); delete fButtonGroup; } } fButtonGroup = sButtonGroups[groupName]; if (!fButtonGroup) { fButtonGroup = new QButtonGroup(); fButtonGroup->setObjectName(groupName); sButtonGroups[groupName] = fButtonGroup; } fButtonGroup->addButton(this); }
bool QBluetoothServiceInfoPrivate::unregisterService() { if (!registered) return false; if (serverChannel() == -1) return false; if ( __fakeServerPorts.key(serverChannel()) != 0) { #ifdef QT_QNX_BT_BLUETOOTH QByteArray b_uuid = attributes.value(QBluetoothServiceInfo::ServiceId). value<QBluetoothUuid>().toByteArray(); b_uuid = b_uuid.mid(1, b_uuid.length() - 2); if (bt_spp_close_server(b_uuid.data()) == -1) return false; #else if (!ppsSendControlMessage("deregister_server", 0x1101, attributes.value(QBluetoothServiceInfo::ServiceId).value<QBluetoothUuid>(), QString(), attributes.value(QBluetoothServiceInfo::ServiceName).toString(), __fakeServerPorts.key(serverChannel()), BT_SPP_SERVER_SUBTYPE)) { return false; } #endif else { __fakeServerPorts.remove(__fakeServerPorts.key(serverChannel())); registered = false; return true; } } else { return false; } }
int main(int argc, char **argv) { Q_UNUSED(argc); Q_UNUSED(argv); basicCheck(); QHash<QString, int> hash; Trie<int> t; while (hash.count() < 500) { qDebug() << hash.count(); QStringList key = generateKey(); int value = qrand() % 50000; hash[key.join(QLatin1String(","))] = value; t.insert(key, value); QHashIterator<QString, int> i(hash); while (i.hasNext()) { i.next(); if (t.find(i.key().split(QLatin1Char(','))).count() == 0) qDebug() << i.key(); Q_ASSERT(t.find(i.key().split(QLatin1Char(','))).count() > 0); if (qrand() % 500 == 0) { t.remove(i.key().split(QLatin1Char(',')), i.value()); hash.remove(i.key()); } //cout << i.key() << ": " << i.value() << endl; } } return 0; }
void InfoSystemCache::pruneTimerFired() { qDebug() << Q_FUNC_INFO << "Pruning infosystemcache"; qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); for ( int i = InfoNoInfo; i <= InfoLastInfo; i++ ) { InfoType type = (InfoType)(i); QHash< QString, QString > fileLocationHash = m_fileLocationCache[type]; const QString cacheDirName = m_cacheBaseDir + QString::number( (int)type ); QFileInfoList fileList = QDir( cacheDirName ).entryInfoList( QDir::Files | QDir::NoDotAndDotDot ); foreach ( QFileInfo file, fileList ) { QString baseName = file.baseName(); if ( file.suffix().toLongLong() < currentMSecsSinceEpoch ) { if ( !QFile::remove( file.canonicalFilePath() ) ) tLog() << "Failed to remove stale cache file" << file.canonicalFilePath(); else qDebug() << "Removed stale cache file" << file.canonicalFilePath(); } if ( fileLocationHash.contains( baseName ) ) fileLocationHash.remove( baseName ); } m_fileLocationCache[type] = fileLocationHash; }
QHash< QString, QString > ImportOEBPS::LoadFolderStructure() { QList< QString > keys = m_Files.keys(); int num_files = keys.count(); QFutureSynchronizer< tuple< QString, QString > > sync; for ( int i = 0; i < num_files; ++i ) { QString id = keys.at( i ); sync.addFuture( QtConcurrent::run( this, &ImportOEBPS::LoadOneFile, m_Files.value( id ), m_FileMimetypes.value( id ) ) ); } sync.waitForFinished(); QList< QFuture< tuple< QString, QString > > > futures = sync.futures(); int num_futures = futures.count(); QHash< QString, QString > updates; for ( int i = 0; i < num_futures; ++i ) { tuple< QString, QString > result = futures.at( i ).result(); updates[ result.get< 0 >() ] = result.get< 1 >(); } updates.remove( UPDATE_ERROR_STRING ); return updates; }
CompositeKey DatabaseOpenWidget::databaseKey() { CompositeKey masterKey; if (m_ui->checkPassword->isChecked()) { masterKey.addKey(PasswordKey(m_ui->editPassword->text())); } QHash<QString, QVariant> lastKeyFiles = config()->get("LastKeyFiles").toHash(); if (m_ui->checkKeyFile->isChecked()) { FileKey key; QString keyFilename = m_ui->comboKeyFile->currentText(); QString errorMsg; if (!key.load(keyFilename, &errorMsg)) { MessageBox::warning(this, tr("Error"), tr("Can't open key file").append(":\n").append(errorMsg)); return CompositeKey(); } masterKey.addKey(key); lastKeyFiles[m_filename] = keyFilename; } else { lastKeyFiles.remove(m_filename); } if (config()->get("RememberLastKeyFiles").toBool()) { config()->set("LastKeyFiles", lastKeyFiles); } return masterKey; }
//お気に入りを更新 void WebPageForm::Private::updateFavorite(const QString &url, const QString &title, bool add) { bool exist = false; bool update = false; settings.beginGroup(QStringLiteral(FAV_USER)); QHash<QString, QVariant> list = settings.value(QStringLiteral(FAV_USER_BOOKMARK)).toHash(); foreach (const QString &key, list.keys()) { if(url == key){ //見つかった exist = true; if(add){ //追加(ただしすでにある) }else{ //削除 list.remove(url); update = true; } break; } } if(!exist){ list.insert(url, title); update = true; } if(update) settings.setValue(QStringLiteral(FAV_USER_BOOKMARK), list); settings.endGroup(); settings.sync(); if(update) emit q->updateFavorite(); }
QSpotifyPlaylistContainer::~QSpotifyPlaylistContainer() { g_containerObjects.remove(m_container); sp_playlistcontainer_remove_callbacks(m_container, m_callbacks, 0); qDeleteAll(m_playlists); sp_playlistcontainer_release(m_container); delete m_callbacks; }
void UmlOperation::java(QHash<QByteArray, QByteArray*> & prop) { QByteArray d = JavaSettings::operationDef(); QByteArray * v; if ((v = prop.value("Java/Final")) != 0) { if (*v == "TRUE") set_isJavaFinal(TRUE); prop.remove("Java/Final"); } if ((v = prop.value("Java/Synchronized")) != 0) { if (*v == "TRUE") set_isJavaSynchronized(TRUE); prop.remove("Java/Synchronized"); } if ((v = prop.value("Java/Static")) != 0) { if (*v == "TRUE") set_isClassMember(TRUE); prop.remove("Java/Static"); } if ((v = prop.value("Java/Abstract")) != 0) { if (*v == "TRUE") set_isAbstract(TRUE); prop.remove("Java/Abstract"); } if ((v = prop.value("Java/Strictfp")) != 0) { if (*v == "TRUE") { int index = d.indexOf("${final}"); if (index != -1) d.insert(index, "strictfp "); } prop.remove("Java/Strictfp"); } set_JavaDef(d); }
void RewriteActionCompressor::compressImports(QList<RewriteAction *> &actions) const { QList<RewriteAction *> actionsToRemove; QHash<Import, RewriteAction *> addedImports; QHash<Import, RewriteAction *> removedImports; QMutableListIterator<RewriteAction *> iter(actions); iter.toBack(); while (iter.hasPrevious()) { RewriteAction *action = iter.previous(); if (RemoveImportRewriteAction *removeImportAction = action->asRemoveImportRewriteAction()) { const Import import = removeImportAction->import(); if (removedImports.contains(import)) { actionsToRemove.append(action); } else if (RewriteAction *addImportAction = addedImports.value(import, 0)) { actionsToRemove.append(action); actionsToRemove.append(addImportAction); addedImports.remove(import); delete addImportAction; } else { removedImports.insert(import, action); } } else if (AddImportRewriteAction *addImportAction = action->asAddImportRewriteAction()) { const Import import = addImportAction->import(); if (RewriteAction *duplicateAction = addedImports.value(import, 0)) { actionsToRemove.append(duplicateAction); addedImports.remove(import); delete duplicateAction; addedImports.insert(import, action); } else if (RewriteAction *removeAction = removedImports.value(import, 0)) { actionsToRemove.append(action); actionsToRemove.append(removeAction); removedImports.remove(import); delete removeAction; } else { addedImports.insert(import, action); } } } foreach (RewriteAction *action, actionsToRemove) { actions.removeOne(action); delete action; }
bool GlobalHotImpl::unregister_hot(const QKeySequence &keys) { if (keys.isEmpty()) return false; Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; quint32 code = native_keycode(Qt::Key((keys[0] ^ allMods) & keys[0])); quint32 mods = native_modifiers(Qt::KeyboardModifiers(keys[0] & allMods)); unregister_hot(code, mods); m_shortcuts.remove(qMakePair(code, mods)); return true; }
void FdoSelectionManagerPrivate::handleCancelMessage(const XClientMessageEvent &event) { const WId winId = event.window; const long messageId = event.data.l[2]; if (messageRequests.contains(winId) && messageRequests[winId].messageId == messageId) { messageRequests.remove(winId); } }
void QSpotifySearch::clearSearch(sp_search *search) { QMutexLocker lock(&g_mutex); if (search) sp_search_release(search); g_searchObjects.remove(search); if (search == m_sp_search) m_sp_search = nullptr; }
bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) { Identifier id(nativeMods, nativeKey); if (!keyIDs.contains(id)) return false; EventHotKeyRef ref = keyRefs.take(keyIDs[id]); keyIDs.remove(id); return !UnregisterEventHotKey(ref); }
void HyperBusReciever::destroyStaticHyperBus(const QString &key) { HyperBusReciever *res = static_hyperbus_objs.value(key); if(!res) return; static_hyperbus_objs.remove(key); delete res; }