StringTable::stringCode 
TopRegionRequest::getStatus() const {
// report DONE
   switch ( m_state ) {
      case TOP_REGION:
         // to be able to somewhat gracefully handle map updates ie updates
         // of one of the available module sets we don't want to report timeout
         // if at least some of the reply packets have been received
         if (m_matches.size() == 0)
            return StringTable::TIMEOUT_ERROR;
         else {
            if (!isCacheable()) {
               mc2log << warn << "[TopRegionRequest] not complete, missing "
                      << "answer from at least one leader. Result is not "
                      << "cacheable." << endl;
            }
            return StringTable::OK;
         }
      case DONE:
         return StringTable::OK;
      case ERROR:
         return StringTable::INTERNAL_SERVER_ERROR;
   }

   // Unreachable code
   return StringTable::INTERNAL_SERVER_ERROR;
}
Example #2
0
PassRefPtr<RegExp> RegExpCache::lookupOrCreate(const UString& patternString, const UString& flags)
{
    if (isCacheable(patternString)) {
        pair<HashMap<RegExpKey, RefPtr<RegExp> >::iterator, bool> result = m_cacheMap.add(RegExpKey(flags, patternString), 0);
        if (!result.second)
            return result.first->second;
    }
    return create(patternString, flags);
}
QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const
{
    QIcon retIcon;
    const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
    if (!theme)
        return retIcon;

    QList<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
    if (sizes.isEmpty())
        return retIcon;

    const QString keyBase = QLatin1String("qt_.") + fi.suffix().toUpper();

    bool cacheable = isCacheable(fi);
    if (cacheable) {
        QPixmap pixmap;
        QPixmapCache::find(keyBase + QString::number(sizes.at(0)), pixmap);
        if (!pixmap.isNull()) {
            bool iconIsComplete = true;
            retIcon.addPixmap(pixmap);
            for (int i = 1; i < sizes.count(); i++)
                if (QPixmapCache::find(keyBase + QString::number(sizes.at(i)), pixmap)) {
                    retIcon.addPixmap(pixmap);
                } else {
                    iconIsComplete = false;
                    break;
                }
            if (iconIsComplete)
                return retIcon;
        }
    }

    QPlatformTheme::IconOptions iconOptions;
    if (options & QFileIconProvider::DontUseCustomDirectoryIcons)
        iconOptions |= QPlatformTheme::DontUseCustomDirectoryIcons;

    Q_FOREACH (int size, sizes) {
        QPixmap pixmap = theme->fileIconPixmap(fi, QSizeF(size, size), iconOptions);
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (cacheable)
                QPixmapCache::insert(keyBase + QString::number(size), pixmap);
        }
    }
 DocIdSetIteratorPtr FieldCacheDocIdSet::iterator()
 {
     // Synchronization needed because deleted docs BitVector can change after call to hasDeletions until 
     // TermDocs creation.  We only use an iterator with termDocs, when this was requested (eg. range 
     // contains 0) and the index has deletions
     TermDocsPtr termDocs;
     {
         SyncLock instancesLock(reader);
         termDocs = isCacheable() ? TermDocsPtr() : reader->termDocs(TermPtr());
     }
     if (termDocs)
     {
         // a DocIdSetIterator using TermDocs to iterate valid docIds
         return newLucene<FieldDocIdSetIteratorTermDocs>(shared_from_this(), termDocs);
     }
     else
     {
         // a DocIdSetIterator generating docIds by incrementing a variable - this one can be used if there 
         // are no deletions are on the index
         return newLucene<FieldDocIdSetIteratorIncrement>(shared_from_this());
     }
 }
Example #5
0
QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
{
    QIcon retIcon;
    static int defaultFolderIIcon = -1;

    QString key;
    QPixmap pixmap;
    // If it's a file, non-{exe,lnk,ico} then we might have it cached already
    if (isCacheable(fileInfo)) {
        const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper();
        key = QLatin1String("qt_") + fileExtension;
        QPixmapCache::find(key, pixmap);
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                retIcon.addPixmap(pixmap);
            return retIcon;
        }
    }

    const bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot();
    if (!useCustomDirectoryIcons && defaultFolderIIcon >= 0 && cacheableDirIcon) {
        // We already have the default folder icon, just return it
        key = QString::fromLatin1("qt_dir_%1").arg(defaultFolderIIcon);
        QPixmapCache::find(key, pixmap);
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                retIcon.addPixmap(pixmap);
            return retIcon;
        }
    }

    /* We don't use the variable, but by storing it statically, we
     * ensure CoInitialize is only called once. */
    static HRESULT comInit = CoInitialize(NULL);
    Q_UNUSED(comInit);

    SHFILEINFO info;
    unsigned long val = 0;

    //Get the small icon
    unsigned int flags =
#ifndef Q_OS_WINCE
        SHGFI_ICON|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX;
#else
        SHGFI_SYSICONINDEX;
#endif

    if (cacheableDirIcon && !useCustomDirectoryIcons) {
        flags |= SHGFI_USEFILEATTRIBUTES;
        val = SHGetFileInfo(L"dummy",
                            FILE_ATTRIBUTE_DIRECTORY, &info,
                            sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
    } else {
        val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(),
                            0, &info, sizeof(SHFILEINFO), flags | SHGFI_SMALLICON);
    }

    // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
    if (val && info.hIcon) {
        if (fileInfo.isDir() && !fileInfo.isRoot()) {
            if (!useCustomDirectoryIcons && defaultFolderIIcon < 0)
                defaultFolderIIcon = info.iIcon;
            //using the unique icon index provided by windows save us from duplicate keys
            key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
            QPixmapCache::find(key, pixmap);
            if (!pixmap.isNull()) {
                retIcon.addPixmap(pixmap);
                if (QPixmapCache::find(key + QLatin1Char('l'), pixmap))
                    retIcon.addPixmap(pixmap);
                DestroyIcon(info.hIcon);
                return retIcon;
            }
        }
        if (pixmap.isNull()) {
#ifndef Q_OS_WINCE
            pixmap = QPixmap::fromWinHICON(info.hIcon);
#else
            pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
#endif
            if (!pixmap.isNull()) {
                retIcon.addPixmap(pixmap);
                if (!key.isEmpty())
                    QPixmapCache::insert(key, pixmap);
            }
            else {
              qWarning("QFileIconProviderPrivate::getWinIcon() no small icon found");
            }
        }
        DestroyIcon(info.hIcon);
    }

    //Get the big icon
    val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(),
                0, &info, sizeof(SHFILEINFO), flags | SHGFI_LARGEICON);

    if (val && info.hIcon) {
        if (fileInfo.isDir() && !fileInfo.isRoot()) {
            //using the unique icon index provided by windows save us from duplicate keys
            key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon);
        }
#ifndef Q_OS_WINCE
        pixmap = QPixmap::fromWinHICON(info.hIcon);
#else
        pixmap = QPixmap::fromWinHICON(ImageList_GetIcon((HIMAGELIST) val, info.iIcon, ILD_NORMAL));
#endif
        if (!pixmap.isNull()) {
            retIcon.addPixmap(pixmap);
            if (!key.isEmpty())
                QPixmapCache::insert(key + QLatin1Char('l'), pixmap);
        }
        else {
            qWarning("QFileIconProviderPrivate::getWinIcon() no large icon found");
        }
        DestroyIcon(info.hIcon);
    }
    return retIcon;
}
Example #6
0
void StyleSheetContents::removedFromMemoryCache()
{
    ASSERT(m_isInMemoryCache);
    ASSERT(isCacheable());
    m_isInMemoryCache = false;
}
Example #7
0
void StyleSheetContents::addedToMemoryCache()
{
    ASSERT(!m_isInMemoryCache);
    ASSERT(isCacheable());
    m_isInMemoryCache = true;
}
Example #8
0
bool StyleSheetContents::hasFailedOrCanceledSubresources() const
{
    ASSERT(isCacheable());
    return childRulesHaveFailedOrCanceledSubresources(m_childRules);
}