예제 #1
0
QModelIndex QFileSystemModelEx::index(const QString &path, int column) const
{
	QFileInfo info(path);
	if(info.exists() && info.isDir())
	{
		QString fullPath = QDir::fromNativeSeparators(info.canonicalFilePath());
		QStringList parts = fullPath.split('/', QString::SkipEmptyParts);
		for(int i = 2; i <= parts.count(); i++)
		{
			QFileInfo currentPath(((QStringList) parts.mid(0, i)).join("/"));
			if((!currentPath.exists()) || (!currentPath.isDir()) || currentPath.isHidden())
			{
				return QModelIndex();
			}
		}
		QModelIndex index = QFileSystemModel::index(fullPath, column);
		if(index.isValid())
		{
			QModelIndex temp = index;
			while(temp.isValid())
			{
				removeFromCache(filePath(temp).toLower());
				temp = temp.parent();
			}
			return index;
		}
	}
	return QModelIndex();
}
void ctkPluginFrameworkListeners::removeServiceSlot(QSharedPointer<ctkPlugin> plugin,
                                                    QObject* receiver,
                                                    const char* slot)
{
  QMutexLocker lock(&mutex); Q_UNUSED(lock)

  ctkServiceSlotEntry entryToRemove(plugin, receiver, slot);
  QMutableSetIterator<ctkServiceSlotEntry> it(serviceSet);
  while (it.hasNext())
  {
    ctkServiceSlotEntry currentEntry = it.next();
    if (currentEntry == entryToRemove)
    {
      currentEntry.setRemoved(true);
      //listeners.framework.hooks.handleServiceListenerUnreg(sle);
      removeFromCache(currentEntry);
      it.remove();
      if (slot) break;
    }
  }

  if (plugin)
  {
    disconnect(receiver, SIGNAL(destroyed(QObject*)), this, SLOT(serviceListenerDestroyed(QObject*)));
  }
}
예제 #3
0
void QFileSystemModelEx::fetchMore(const QModelIndex &parent)
{
	if(parent.isValid())
	{
		removeFromCache(filePath(parent).toLower());
	}

	QFileSystemModel::fetchMore(parent);
}
예제 #4
0
void RefImage::insertImage(QPixmap pixmap, QString name)
{
    m_imageItem = new ManipulableItem(pixmap, name, this);
    setImageCached(true);

    connect(imageItem(),SIGNAL(destroyed()),this,SLOT(removeFromCache()));
    connect(imageItem(),SIGNAL(infoChanged()),this,SIGNAL(infoChanged()));

    emit newImage(imageItem());
}
bool LLTextureCache::updateTextureEntryList(const LLUUID& id, S32 bodysize)
{
	bool res = false;
	bool purge = false;
	{
		mHeaderMutex.lock();
		size_map_t::iterator iter1 = mTexturesSizeMap.find(id);
		if (iter1 == mTexturesSizeMap.end() || iter1->second < bodysize)
		{
			llassert_always(bodysize > 0);

			S32 oldbodysize = 0;
			if (iter1 != mTexturesSizeMap.end())
			{
				oldbodysize = iter1->second;
			}
						
			Entry entry;
			S32 idx = openAndReadEntry(id, entry, false);
			if (idx < 0)
			{
				// TODO: change to llwarns
				llerrs << "Failed to open entry: " << id << llendl;
				mHeaderMutex.unlock();
				removeFromCache(id);
				return false;
			}			
			else if (oldbodysize != entry.mBodySize)
			{
				// TODO: change to llwarns
				llerrs << "Entry mismatch in mTextureSizeMap / mHeaderIDMap"
					   << " idx=" << idx << " oldsize=" << oldbodysize << " entrysize=" << entry.mBodySize << llendl;
			}
			entry.mBodySize = bodysize;
			writeEntryAndClose(idx, entry);
			
			mTexturesSizeTotal -= oldbodysize;
			mTexturesSizeTotal += bodysize;
			
			if (mTexturesSizeTotal > sCacheMaxTexturesSize)
			{
				purge = true;
			}
			res = true;
		}
	}
	if (purge)
	{
		mDoPurge = TRUE;
	}
	mHeaderMutex.unlock();
	return res;
}
예제 #6
0
void LLVOCache::purgeEntries(U32 size)
{
	while(mHeaderEntryQueue.size() > size)
	{
		header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ;
		HeaderEntryInfo* entry = *iter ;			
		mHandleEntryMap.erase(entry->mHandle);
		mHeaderEntryQueue.erase(iter) ;
		removeFromCache(entry) ;
		delete entry;
	}
	mNumEntries = mHandleEntryMap.size() ;
}
예제 #7
0
void LLVOCache::purgeEntries()
{
	U32 limit = mCacheSize - NUM_ENTRIES_TO_PURGE ;
	while(mHeaderEntryQueue.size() > limit)
	{
		header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ;
		HeaderEntryInfo* entry = *iter ;
		
		removeFromCache(entry->mHandle) ;
		mHandleEntryMap.erase(entry->mHandle) ;		
		mHeaderEntryQueue.erase(iter) ;
		delete entry ;
	}

	writeCacheHeader() ;
	readCacheHeader() ;
	mNumEntries = mHandleEntryMap.size() ;
}
예제 #8
0
int CacheSyncSource::deleteItem(SyncItem& item) {
    int ret = removeItem(item);
    switch (ret) {        
        case 200:
        case 201:
        case 418: {
            LOG.info("[%s] Successful delete of item with key %s - code %d", getName(), item.getKey(), ret);  
            char* t = toMultibyte(item.getKey());
            KeyValuePair k (t, "");
            removeFromCache(k);
            delete [] t;
        }
        break;
        default:
            LOG.error("[%s] Failed delete of item with key %s - code %d", getName(), item.getKey(), ret);
        break;
    }
    
    return ret;
} 
예제 #9
0
void LLVOCache::removeEntry(HeaderEntryInfo* entry) 
{
	llassert_always(mInitialized) ;
	if(mReadOnly)
	{
		return ;
	}
	if(!entry)
	{
		return ;
	}

	header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry) ;
	if(iter != mHeaderEntryQueue.end())
	{		
		mHandleEntryMap.erase(entry->mHandle) ;		
		mHeaderEntryQueue.erase(iter) ;
		removeFromCache(entry) ;
		delete entry ;

		mNumEntries = mHandleEntryMap.size() ;
	}
}
예제 #10
0
void BalRuntimeObjectImp::invalidate()
{
    removeFromCache();
    RuntimeObjectImp::invalidate();
}
예제 #11
0
BalRuntimeObjectImp::~BalRuntimeObjectImp()
{
    removeFromCache();
}
// Called from either the main thread or the worker thread
void LLTextureCache::readHeaderCache()
{
	mHeaderMutex.lock();

	mLRU.clear(); // always clear the LRU

	readEntriesHeader();
	
	if (mHeaderEntriesInfo.mVersion != sHeaderCacheVersion)
	{
		if (!mReadOnly)
		{
			purgeAllTextures(false);
		}
	}
	else
	{
		std::vector<Entry> entries;
		U32 num_entries = openAndReadEntries(entries);
		if (num_entries)
		{
			U32 empty_entries = 0;
			typedef std::pair<U32, LLUUID> lru_data_t;
			std::set<lru_data_t> lru;
			std::vector<LLUUID> purge_list;
			for (U32 i=0; i<num_entries; i++)
			{
				Entry& entry = entries[i];
				const LLUUID& id = entry.mID;
				if (entry.mImageSize < 0)
				{
					// This will be in the Free List, don't put it in the LRU
					++empty_entries;
				}
				else
				{
					lru.insert(std::make_pair(entry.mTime, id));
					if (entry.mBodySize > 0)
					{
						if (entry.mBodySize > entry.mImageSize)
						{
							// Shouldn't happen, failsafe only
							llwarns << "Bad entry: " << i << ": " << id << ": BodySize: " << entry.mBodySize << llendl;
							purge_list.push_back(id);
						}
					}
				}
			}
			if (num_entries > sCacheMaxEntries)
			{
				// Special case: cache size was reduced, need to remove entries
				// Note: After we prune entries, we will call this again and create the LRU
				U32 entries_to_purge = (num_entries-empty_entries) - sCacheMaxEntries;
				if (entries_to_purge > 0)
				{
					for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter)
					{
						purge_list.push_back(iter->second);
						if (--entries_to_purge <= 0)
							break;
					}
				}
			}
			else
			{
				S32 lru_entries = (S32)((F32)sCacheMaxEntries * TEXTURE_CACHE_LRU_SIZE);
				for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter)
				{
					mLRU.insert(iter->second);
// 					llinfos << "LRU: " << iter->first << " : " << iter->second << llendl;
					if (--lru_entries <= 0)
						break;
				}
			}
			
			if (purge_list.size() > 0)
			{
				for (std::vector<LLUUID>::iterator iter = purge_list.begin(); iter != purge_list.end(); ++iter)
				{
					mHeaderMutex.unlock(); 
					removeFromCache(*iter);
					mHeaderMutex.lock();
				}
				// If we removed any entries, we need to rebuild the entries list,
				// write the header, and call this again
				std::vector<Entry> new_entries;
				for (U32 i=0; i<num_entries; i++)
				{
					const Entry& entry = entries[i];
					if (entry.mImageSize >=0)
					{
						new_entries.push_back(entry);
					}
				}
				llassert_always(new_entries.size() <= sCacheMaxEntries);
				mHeaderEntriesInfo.mEntries = new_entries.size();
				writeEntriesAndClose(new_entries);
				mHeaderMutex.unlock(); // unlock the mutex before calling again
				readHeaderCache(); // repeat with new entries file
				mHeaderMutex.lock();
			}
			else
			{
				writeEntriesAndClose(entries);
			}
		}
	}
	mHeaderMutex.unlock();
}
예제 #13
0
void KoStyleThumbnailer::removeFromCache(KoCharacterStyle *style)
{
    QString imageKey = "c_" + QString::number(reinterpret_cast<unsigned long>(style)) + "_";
    removeFromCache(imageKey);
}
예제 #14
0
INT_PTR CALLBACK DlgProcOptsStringChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {

    switch (msg) {
	case WM_INITDIALOG: {
		DBVARIANT dbv;
		DWORD triggerID;
		
		TranslateDialogDefault(hwndDlg);
		triggerID = (DWORD)lParam;
		if (!DBGetTriggerSetting(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, &dbv)) {
			SetDlgItemTextA(hwndDlg, IDC_FORMATTEXT, dbv.pszVal);
			DBFreeVariant(&dbv);
		}
		variables_skin_helpbutton(hwndDlg, IDC_SHOWHELP);
		break;
						}

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
			case IDC_SHOWHELP: {
				variables_showhelp(hwndDlg, IDC_FORMATTEXT, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
				break;
							   }
		}
		break;

	case TM_ADDTRIGGER: {
		// wParam = trigger ID
		// lParam = (TRIGGERREGISTER *)
		DWORD triggerID;
		TCHAR *tszFormatText;

		triggerID = (DWORD)wParam;
		tszFormatText = Hlp_GetDlgItemText(hwndDlg, IDC_FORMATTEXT);
		if (tszFormatText != NULL) {
			DBWriteTriggerSettingTString(triggerID, NULL, MODULENAME, SETTING_TRIGGERTEXT, tszFormatText);
			free(tszFormatText);
		}
		addToCache(triggerID);
		break;
						}
	
	case TM_DELTRIGGER: {
		// wParam = triggerID
		// lParam = (TRIGGEREGISTER *) may be 0
		DWORD triggerID;
		REMOVETRIGGERSETTINGS rts;
		
		triggerID = (DWORD)wParam;
		removeFromCache(triggerID);
		rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
		rts.prefix = PREFIX_TRIGGERID;
		rts.id = triggerID;
		rts.hContact = NULL;
		rts.szModule = MODULENAME;
		CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
		break;
						}
	}

    return FALSE;
}
예제 #15
0
void Database::indexCreate(IndexDefinition &indexDef) {

  if(indexDef.getColumnCount() < 1 || indexDef.getColumnCount() >= MAXKEYFIELDCOUNT) {
    /* must be < MAXKEYFIELDCOUNT because there has to be DbAddr at the end */
    throwSqlError(SQL_KEY_TOO_BIG,_T("Invalid columncount (=%d)"),indexDef.getColumnCount());
  }

  if(indexDef.getIndexType() != INDEXTYPE_PRIMARY &&
     indexDef.getIndexType() != INDEXTYPE_UNIQUE  &&
     indexDef.getIndexType() != INDEXTYPE_NON_UNIQUE) {
     throwSqlError(SQL_INVALID_INDEXTYPE,_T("Invalid indextype (=%d)"),indexDef.getIndexType());
  }

  if(indexDef.m_fileName.length() == 0) {
    indexDef.m_fileName = getNewFileName(_T("KEY"));
  }

  if(indexDef.m_indexName.length() == 0) {
    if(indexDef.getIndexType() == INDEXTYPE_PRIMARY) {
      indexDef.m_indexName = indexDef.m_tableName;
    } else {
      throwSqlError(SQL_INVALID_INDEXNAME,_T("Invalid indexname:<%s>"),indexDef.m_indexName.cstr());
    }
  }

  if(DbFile::exist(indexDef.m_fileName)) {
    throwSqlError(SQL_FILE_ALREADY_EXIST,_T("File <%s> already exist"),indexDef.m_fileName.cstr());
  }

  indexDef.m_tableName = toUpperCase(indexDef.m_tableName);
  indexDef.m_indexName = toUpperCase(indexDef.m_indexName);
  indexDef.m_fileName  = toUpperCase(indexDef.m_fileName);

  const TableDefinition &tableDef = getTableDefinition(indexDef.m_tableName);

  if(tableDef.getTableType() != TABLETYPE_USER) {
    throwSqlError(SQL_INVALID_TABLETYPE,_T("Invalid tabletype (=%c)"),tableDef.getTableType());
  }

/* check that the indexname is not already used */

  KeyFile indexfile2(*this,SYSTEM_INDEXKEY2_FNAME, DBFMODE_READWRITE);
  KeyFileDefinition keydef2(indexfile2);
  KeyType key2;
  keydef2.put(key2,0,indexDef.m_indexName );
  if(indexfile2.searchMin(RELOP_EQ, key2, 1)) {
    throwSqlError(SQL_INDEX_ALREADY_EXIST,_T("Index <%s> already exist"),indexDef.m_indexName.cstr());
  }

  if(!inTMF()) {
    throwSqlError(SQL_NO_TRANSACTION,_T("indexCreate:No active tmf"));
  }

  KeyFileDefinition keydef = tableDef.getKeyFileDefinition(indexDef);

  KeyFile::create(indexDef.m_fileName, keydef);

  try {
    KeyFile  keyFile( indexDef.m_fileName, DBFMODE_READWRITE, false);
    DataFile datafile(tableDef.getFileName(), DBFMODE_READONLY , false);
    const TableInfo &tableInfo = getTableInfo(tableDef.getTableName());

  /* TODO Lock datafile to avoid new records to be inserted */

    if(indexDef.getIndexType() != INDEXTYPE_PRIMARY) {
      dataFileScan(indexDef.m_tableName, KeyGenerator(*this, keyFile, indexDef, tableInfo, keydef));
    }

    sysTabIndexInsert(indexDef);

  /* TODO Invalidate all binded program-packages; Unlock datafile */
  } catch(sqlca) {
    DbFile::destroy(indexDef.m_fileName);
    throw;
  }
  removeFromCache(indexDef.m_tableName);
}