changed DirDetails::children to be a vector, removed costly caching of DirDetailVector

This commit is contained in:
mr-alice 2016-08-19 18:49:42 +02:00
parent 78b8744183
commit f8ed1d3fb7
10 changed files with 124 additions and 116 deletions

View file

@ -545,6 +545,8 @@ bool DirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
const InternalFileHierarchyStorage::DirEntry *dir_entry = mFileHierarchy->getDirEntry(indx) ; const InternalFileHierarchyStorage::DirEntry *dir_entry = mFileHierarchy->getDirEntry(indx) ;
d.ref = (void*)(intptr_t)indx ;
if (dir_entry != NULL) /* has children --- fill */ if (dir_entry != NULL) /* has children --- fill */
{ {
#ifdef DEBUG_DIRECTORY_STORAGE #ifdef DEBUG_DIRECTORY_STORAGE

View file

@ -108,11 +108,12 @@ int p3FileDatabase::tick()
if(last_print_time + 20 < now) if(last_print_time + 20 < now)
{ {
RS_STACK_MUTEX(mFLSMtx) ; RS_STACK_MUTEX(mFLSMtx) ;
mLocalSharedDirs->print(); mLocalSharedDirs->print();
last_print_time = now ; last_print_time = now ;
#warning this should be removed, but it's necessary atm for updating the GUI //#warning this should be removed, but it's necessary atm for updating the GUI
RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0); // RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0);
} }
if(mUpdateFlags) if(mUpdateFlags)
@ -402,12 +403,13 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
convertEntryIndexToPointer((intptr_t)d.ref,fi,d.ref) ; convertEntryIndexToPointer((intptr_t)d.ref,fi,d.ref) ;
for(std::list<DirStub>::iterator it(d.children.begin());it!=d.children.end();++it) for(uint32_t i=0;i<d.children.size();++i)
convertEntryIndexToPointer((intptr_t)it->ref,fi,it->ref); convertEntryIndexToPointer((intptr_t)d.children[i].ref,fi,d.children[i].ref);
#define Make sure this is right.
if(e == 0) if(e == 0)
{ {
d.prow = fi-1 ; d.prow = 0;//fi-1 ;
d.parent = NULL ; d.parent = NULL ;
} }
else else

View file

@ -242,7 +242,7 @@ public:
FileStorageFlags flags; FileStorageFlags flags;
uint32_t min_age ; // minimum age of files in this subtree uint32_t min_age ; // minimum age of files in this subtree
std::list<DirStub> children; std::vector<DirStub> children;
std::list<std::string> parent_groups; // parent groups for the shared directory std::list<std::string> parent_groups; // parent groups for the shared directory
}; };

View file

@ -60,7 +60,7 @@ std::ostream &operator<<(std::ostream &out, const DirDetails& d)
std::cerr << " Min age : " << d.min_age << std::endl; std::cerr << " Min age : " << d.min_age << std::endl;
std::cerr << " Flags : " << d.flags << std::endl; std::cerr << " Flags : " << d.flags << std::endl;
std::cerr << " Parent groups : " ; for(std::list<std::string>::const_iterator it(d.parent_groups.begin());it!=d.parent_groups.end();++it) std::cerr << (*it) << " "; std::cerr << std::endl; std::cerr << " Parent groups : " ; for(std::list<std::string>::const_iterator it(d.parent_groups.begin());it!=d.parent_groups.end();++it) std::cerr << (*it) << " "; std::cerr << std::endl;
std::cerr << " Children : " ; for(std::list<DirStub>::const_iterator it(d.children.begin());it!=d.children.end();++it) std::cerr << (intptr_t)(*it).ref << " "; std::cerr << std::endl; std::cerr << " Children : " ; for(uint32_t i=0;i<d.children.size();++i) std::cerr << (intptr_t)d.children[i].ref << " "; std::cerr << std::endl;
std::cerr << "===================" << std::endl; std::cerr << "===================" << std::endl;
return out; return out;
} }

View file

@ -1042,9 +1042,10 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
} }
/* go through all children directories/files for a recursive call */ /* go through all children directories/files for a recursive call */
for (std::list<DirStub>::const_iterator it(dir.children.begin()); it != dir.children.end(); ++it) { for (uint32_t i=0;i<dir.children.size();++i)
{
DirDetails details; DirDetails details;
rsFiles->RequestDirDetails(it->ref, details, FileSearchFlags(0u)); rsFiles->RequestDirDetails(dir.children[i].ref, details, FileSearchFlags(0u));
insertDirectory(txt, searchId, details, child); insertDirectory(txt, searchId, details, child);
} }
} }

View file

@ -99,9 +99,8 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
void *ref = parent.internalPointer(); void *ref = parent.internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!requestDirDetails(ref, RemoteMode,details))
if (!details)
{ {
/* error */ /* error */
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
@ -111,7 +110,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
return false; return false;
} }
if (details->type == DIR_TYPE_FILE) if (details.type == DIR_TYPE_FILE)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "lookup FILE -> false"; std::cerr << "lookup FILE -> false";
@ -124,7 +123,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
std::cerr << "lookup PER/DIR #" << details->count; std::cerr << "lookup PER/DIR #" << details->count;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
return (details->count > 0); /* do we have children? */ return (details.count > 0); /* do we have children? */
} }
bool FlatStyle_RDM::hasChildren(const QModelIndex &parent) const bool FlatStyle_RDM::hasChildren(const QModelIndex &parent) const
{ {
@ -155,9 +154,9 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
void *ref = (parent.isValid())? parent.internalPointer() : NULL ; void *ref = (parent.isValid())? parent.internalPointer() : NULL ;
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details) if (! requestDirDetails(ref, RemoteMode,details))
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "lookup failed -> 0"; std::cerr << "lookup failed -> 0";
@ -165,7 +164,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
#endif #endif
return 0; return 0;
} }
if (details->type == DIR_TYPE_FILE) if (details.type == DIR_TYPE_FILE)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "lookup FILE: 0"; std::cerr << "lookup FILE: 0";
@ -179,7 +178,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
std::cerr << "lookup PER/DIR #" << details->count; std::cerr << "lookup PER/DIR #" << details->count;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
return details->count; return details.count;
} }
int FlatStyle_RDM::rowCount(const QModelIndex &parent) const int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
@ -381,16 +380,16 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const
{ {
QString dir ; QString dir ;
const DirDetails *det = requestDirDetails(details.parent,RemoteMode); DirDetails det ;
if(!det) if(!requestDirDetails(details.parent,RemoteMode,det))
return QString(); return QString();
#ifdef SHOW_TOTAL_PATH #ifdef SHOW_TOTAL_PATH
do do
{ {
#endif #endif
dir = QString::fromUtf8(det->name.c_str())+"/"+dir ; dir = QString::fromUtf8(det.name.c_str())+"/"+dir ;
#ifdef SHOW_TOTAL_PATH #ifdef SHOW_TOTAL_PATH
if(!requestDirDetails(det.parent,det,flags)) if(!requestDirDetails(det.parent,det,flags))
@ -521,28 +520,28 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
void *ref = index.internalPointer(); void *ref = index.internalPointer();
int coln = index.column(); int coln = index.column();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details) if (!requestDirDetails(ref, RemoteMode,details))
return QVariant(); return QVariant();
if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */ if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */
return QString::fromUtf8(details->name.c_str()); return QString::fromUtf8(details.name.c_str());
if (role == Qt::TextColorRole) if (role == Qt::TextColorRole)
{ {
if(details->min_age > ageIndicator) if(details.min_age > ageIndicator)
return QVariant(QColor(Qt::gray)) ; return QVariant(QColor(Qt::gray)) ;
else if(RemoteMode) else if(RemoteMode)
{ {
FileInfo info; FileInfo info;
QVariant local_file_color = QVariant(QColor(Qt::red)); QVariant local_file_color = QVariant(QColor(Qt::red));
if(rsFiles->alreadyHaveFile(details->hash, info)) if(rsFiles->alreadyHaveFile(details.hash, info))
return local_file_color; return local_file_color;
std::list<RsFileHash> downloads; std::list<RsFileHash> downloads;
rsFiles->FileDownloads(downloads); rsFiles->FileDownloads(downloads);
if(std::find(downloads.begin(), downloads.end(), details->hash) != downloads.end()) if(std::find(downloads.begin(), downloads.end(), details.hash) != downloads.end())
return local_file_color; return local_file_color;
else else
return QVariant(); return QVariant();
@ -553,7 +552,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
if(role == Qt::DecorationRole) if(role == Qt::DecorationRole)
return decorationRole(*details,coln) ; return decorationRole(details,coln) ;
/***************** /*****************
Qt::EditRole Qt::EditRole
@ -578,10 +577,10 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
} /* end of TextAlignmentRole */ } /* end of TextAlignmentRole */
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return displayRole(*details,coln) ; return displayRole(details,coln) ;
if (role == SortRole) if (role == SortRole)
return sortRole(index,*details,coln) ; return sortRole(index,details,coln) ;
return QVariant(); return QVariant();
} }
@ -712,9 +711,10 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
} }
********/ ********/
const DirDetailsVector *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details)
if (! requestDirDetails(ref, RemoteMode,details))
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "lookup failed -> invalid"; std::cerr << "lookup failed -> invalid";
@ -728,7 +728,7 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
* get the reference number * get the reference number
*/ */
if (row >= (int) details->childrenVector.size()) if (row >= (int) details.children.size())
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "wrong number of children -> invalid"; std::cerr << "wrong number of children -> invalid";
@ -744,7 +744,7 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
/* we can just grab the reference now */ /* we can just grab the reference now */
return createIndex(row, column, details->childrenVector[row].ref); return createIndex(row, column, details.children[row].ref);
} }
QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent) const QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent) const
{ {
@ -786,9 +786,9 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
} }
void *ref = index.internalPointer(); void *ref = index.internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details) if (! requestDirDetails(ref, RemoteMode,details))
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "Failed Lookup -> invalid"; std::cerr << "Failed Lookup -> invalid";
@ -797,7 +797,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
return QModelIndex(); return QModelIndex();
} }
if (!(details->parent)) if (!(details.parent))
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "success. parent is Root/NULL --> invalid"; std::cerr << "success. parent is Root/NULL --> invalid";
@ -811,7 +811,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
return createIndex(details->prow, 0, details->parent); return createIndex(details.prow, 0, details.parent);
} }
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
{ {
@ -836,12 +836,12 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
void *ref = index.internalPointer(); void *ref = index.internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details) if (! requestDirDetails(ref, RemoteMode,details))
return Qt::ItemIsSelectable; // Error. return Qt::ItemIsSelectable; // Error.
switch(details->type) switch(details.type)
{ {
case DIR_TYPE_PERSON: return Qt::ItemIsEnabled; case DIR_TYPE_PERSON: return Qt::ItemIsEnabled;
case DIR_TYPE_DIR: return Qt::ItemIsSelectable | Qt::ItemIsEnabled; case DIR_TYPE_DIR: return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
@ -902,32 +902,36 @@ void RetroshareDirModel::postMods()
emit layoutChanged(); emit layoutChanged();
} }
const DirDetailsVector *RetroshareDirModel::requestDirDetails(void *ref, bool remote) const bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d) const
{ {
const QMap<void*, DirDetailsVector>::const_iterator it = mCache.constFind(ref);
if (it != mCache.constEnd()) {
/* Details found in cache */
return &it.value();
}
/* Get details from the lib */
DirDetailsVector details;
FileSearchFlags flags = (remote) ? RS_FILE_HINTS_REMOTE : RS_FILE_HINTS_LOCAL; FileSearchFlags flags = (remote) ? RS_FILE_HINTS_REMOTE : RS_FILE_HINTS_LOCAL;
if (rsFiles->RequestDirDetails(ref, details, flags)) {
/* Convert std::list to std::vector for fast access with index */
std::list<DirStub>::const_iterator childIt;
for (childIt = details.children.begin(); childIt != details.children.end(); ++childIt) {
details.childrenVector.push_back(*childIt);
}
/* Add to cache, must cast to none const */ return rsFiles->RequestDirDetails(ref, d, flags) ;
const QMap<void*, DirDetailsVector>::iterator it1 = ((QMap<void*, DirDetailsVector>*) &mCache)->insert(ref, details);
return &it1.value();
}
/* No details found */
return NULL;
} }
// const QMap<void*, DirDetailsVector>::const_iterator it = mCache.constFind(ref);
// if (it != mCache.constEnd()) {
// /* Details found in cache */
// return &it.value();
// }
//
//#warning this is terrible! A vector in a std::map will keep being copied and create a lot of CPU overload. Use a pointer instead.
// /* Get details from the lib */
//
// if (rsFiles->RequestDirDetails(ref, details, flags)) {
// /* Convert std::list to std::vector for fast access with index */
// std::list<DirStub>::const_iterator childIt;
// for (childIt = details.children.begin(); childIt != details.children.end(); ++childIt) {
// details.childrenVector.push_back(*childIt);
// }
//
// /* Add to cache, must cast to none const */
// const QMap<void*, DirDetailsVector>::iterator it1 = ((QMap<void*, DirDetailsVector>*) &mCache)->insert(ref, details);
// return &it1.value();
// }
//
// /* No details found */
// return NULL;
//}
void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list) void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list)
{ {
@ -1010,15 +1014,16 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
if (!dwlDir.mkpath(cleanPath)) return; if (!dwlDir.mkpath(cleanPath)) return;
for (it = dirDetails.children.begin(); it != dirDetails.children.end(); ++it) for(uint32_t i=0;i<dirDetails.children.size();++i)
{ {
if (!it->ref) continue; if (!dirDetails.children[i].ref) continue;
const DirDetails *subDirDetails = requestDirDetails(it->ref, true); DirDetails subDirDetails ;
if (!subDirDetails) continue; if(!requestDirDetails(dirDetails.children[i].ref, true,subDirDetails))
continue;
downloadDirectory(*subDirDetails, prefixLen); downloadDirectory(subDirDetails, prefixLen);
} }
} }
} }
@ -1035,12 +1040,12 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
{ {
void *ref = it -> internalPointer(); void *ref = it -> internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!details) if(!requestDirDetails(ref, RemoteMode,details))
continue; continue;
dirVec.push_back(*details); dirVec.push_back(details);
} }
} }
} }
@ -1072,12 +1077,12 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
{ {
void *ref = it -> internalPointer(); void *ref = it -> internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details;
if (!details) if (!requestDirDetails(ref, RemoteMode,details))
continue; continue;
if(details->type == DIR_TYPE_PERSON) if(details.type == DIR_TYPE_PERSON)
continue ; continue ;
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
@ -1090,10 +1095,10 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
// Note: for directories, the returned hash, is the peer id, so if we collect // Note: for directories, the returned hash, is the peer id, so if we collect
// dirs, we need to be a bit more conservative for the // dirs, we need to be a bit more conservative for the
if(already_in.find(details->hash.toStdString()+details->name) == already_in.end()) if(already_in.find(details.hash.toStdString()+details.name) == already_in.end())
{ {
file_details.push_back(*details) ; file_details.push_back(details) ;
already_in.insert(details->hash.toStdString()+details->name) ; already_in.insert(details.hash.toStdString()+details.name) ;
} }
} }
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
@ -1167,9 +1172,9 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
{ {
void *ref = it -> internalPointer(); void *ref = it -> internalPointer();
const DirDetails *details = requestDirDetails(ref, false); DirDetails details ;
if (!details) if (!requestDirDetails(ref, false,details) )
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "getFilePaths() Bad Request" << std::endl; std::cerr << "getFilePaths() Bad Request" << std::endl;
@ -1177,7 +1182,7 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
continue; continue;
} }
if (details->type != DIR_TYPE_FILE) if (details.type != DIR_TYPE_FILE)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "getFilePaths() Not File" << std::endl; std::cerr << "getFilePaths() Not File" << std::endl;
@ -1187,14 +1192,14 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "::::::::::::File Details:::: " << std::endl; std::cerr << "::::::::::::File Details:::: " << std::endl;
std::cerr << "Name: " << details->name << std::endl; std::cerr << "Name: " << details.name << std::endl;
std::cerr << "Hash: " << details->hash << std::endl; std::cerr << "Hash: " << details.hash << std::endl;
std::cerr << "Size: " << details->count << std::endl; std::cerr << "Size: " << details.count << std::endl;
std::cerr << "Path: " << details->path << std::endl; std::cerr << "Path: " << details.path << std::endl;
#endif #endif
std::string filepath = details->path + "/"; std::string filepath = details.path + "/";
filepath += details->name; filepath += details.name;
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "Constructed FilePath: " << filepath << std::endl; std::cerr << "Constructed FilePath: " << filepath << std::endl;
@ -1222,12 +1227,9 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
{ {
void *ref = it -> internalPointer(); void *ref = it -> internalPointer();
const DirDetails *details = requestDirDetails(ref, RemoteMode); DirDetails details ;
if (!requestDirDetails(ref, RemoteMode,details))
if (!details)
{
continue; continue;
}
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "::::::::::::FileDrag:::: " << std::endl; std::cerr << "::::::::::::FileDrag:::: " << std::endl;
@ -1237,7 +1239,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
std::cerr << "Path: " << details->path << std::endl; std::cerr << "Path: " << details->path << std::endl;
#endif #endif
if (details->type != DIR_TYPE_FILE) if (details.type != DIR_TYPE_FILE)
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RetroshareDirModel::mimeData() Not File" << std::endl; std::cerr << "RetroshareDirModel::mimeData() Not File" << std::endl;
@ -1245,7 +1247,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
continue; /* not file! */ continue; /* not file! */
} }
if (drags.end() != (dit = drags.find(details->hash))) if (drags.end() != (dit = drags.find(details.hash)))
{ {
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "RetroshareDirModel::mimeData() Duplicate" << std::endl; std::cerr << "RetroshareDirModel::mimeData() Duplicate" << std::endl;
@ -1253,9 +1255,9 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
continue; /* duplicate */ continue; /* duplicate */
} }
drags[details->hash] = details->count; drags[details.hash] = details.count;
QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details->name.c_str()), QString::fromStdString(details->hash.toStdString()), QString::number(details->count)); QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details.name.c_str()), QString::fromStdString(details.hash.toStdString()), QString::number(details.count));
if (RemoteMode) if (RemoteMode)
{ {
@ -1348,17 +1350,18 @@ void FlatStyle_RDM::updateRefs()
std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl; std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl;
#endif #endif
_ref_stack.pop_back() ; _ref_stack.pop_back() ;
const DirDetails *details = requestDirDetails(ref, RemoteMode) ;
if (details) DirDetails details ;
if (requestDirDetails(ref, RemoteMode,details))
{ {
if(details->type == DIR_TYPE_FILE) // only push files, not directories nor persons. if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
_ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(*details))); _ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details)));
#ifdef RDM_DEBUG #ifdef RDM_DEBUG
std::cerr << "FlatStyle_RDM::postMods(): adding ref " << ref << std::endl; std::cerr << "FlatStyle_RDM::postMods(): adding ref " << ref << std::endl;
#endif #endif
for(std::list<DirStub>::const_iterator it = details->children.begin(); it != details->children.end(); ++it) for(uint32_t i=0;i<details.children.size();++i)
_ref_stack.push_back(it->ref) ; _ref_stack.push_back(details.children[i].ref) ;
} }
if(++nb_treated_refs > MAX_REFS_PER_SECOND) // we've done enough, let's give back hand to if(++nb_treated_refs > MAX_REFS_PER_SECOND) // we've done enough, let's give back hand to
{ // the user and setup a timer to finish the job later. { // the user and setup a timer to finish the job later.

View file

@ -74,7 +74,7 @@ class RetroshareDirModel : public QAbstractItemModel
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths); void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; } void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
const DirDetailsVector *requestDirDetails(void *ref, bool remote) const; bool requestDirDetails(void *ref, bool remote,DirDetails& d) const;
virtual void update() {} virtual void update() {}
public: public:

View file

@ -544,9 +544,9 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
if (details.type == DIR_TYPE_DIR) if (details.type == DIR_TYPE_DIR)
{ {
for (std::list<DirStub>::const_iterator cit = details.children.begin();cit != details.children.end(); ++cit) for(uint32_t j=0;j<details.children.size();++j)
{ {
const DirStub& dirStub = *cit; const DirStub& dirStub = details.children[j];
DirDetails details; DirDetails details;
FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ; FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;

View file

@ -157,15 +157,15 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
d.setAttribute(QString("name"),QString::fromUtf8(details.name.c_str())) ; d.setAttribute(QString("name"),QString::fromUtf8(details.name.c_str())) ;
for (std::list<DirStub>::const_iterator it = details.children.begin(); it != details.children.end(); ++it) for(uint32_t i=0;i<details.children.size();++i)
{ {
if (!it->ref) if (!details.children[i].ref)
continue; continue;
DirDetails subDirDetails; DirDetails subDirDetails;
FileSearchFlags flags = RS_FILE_HINTS_LOCAL; FileSearchFlags flags = RS_FILE_HINTS_LOCAL;
if (!rsFiles->RequestDirDetails(it->ref, subDirDetails, flags)) if (!rsFiles->RequestDirDetails(details.children[i].ref, subDirDetails, flags))
continue; continue;
recursAddElements(doc,subDirDetails,d) ; recursAddElements(doc,subDirDetails,d) ;

View file

@ -368,7 +368,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) ));
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;