Windows: fix crash in new side filter computation from index

This commit is contained in:
Jean-Francois Dockes 2022-05-18 17:07:21 +01:00
parent be12db218b
commit b9de1ed07e

View File

@ -4,10 +4,12 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include "idxmodel.h"
#include "recoll.h" #include "recoll.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "fstreewalk.h" #include "fstreewalk.h"
#include "idxmodel.h" #include "log.h"
#undef USE_TREEWALK #undef USE_TREEWALK
@ -107,9 +109,9 @@ static void treelist(const std::string& top, const std::vector<std::string>& lst
} }
std::vector<std::string> curpath; std::vector<std::string> curpath;
stringToTokens(top, curpath, "/"); stringToTokens(top, curpath, "/");
//std::cerr << "top " << top << " TOP len is " << curpath.size() << "\n"; LOGDEB0("treelist: " << "top " << top << " TOP depth is " << curpath.size() << "\n");
for (const auto& dir : lst) { for (const auto& dir : lst) {
// std::cerr << "DIR: " << dir << "\n"; LOGDEB1("DIR: " << dir << "\n");
std::vector<std::string> npath; std::vector<std::string> npath;
// Compute the new directory stack // Compute the new directory stack
stringToTokens(dir, npath, "/"); stringToTokens(dir, npath, "/");
@ -138,6 +140,7 @@ static void treelist(const std::string& top, const std::vector<std::string>& lst
void IdxTreeModel::populate() void IdxTreeModel::populate()
{ {
LOGDEB0("IdxTreeModel::populate\n");
QModelIndex index = this->index(0,0); QModelIndex index = this->index(0,0);
if (this->columnCount(index) == 0) { if (this->columnCount(index) == 0) {
if (!this->insertColumn(0, index)) if (!this->insertColumn(0, index))
@ -164,9 +167,13 @@ void IdxTreeModel::populate()
std::vector<std::string> thedirs; std::vector<std::string> thedirs;
std::string prefix; std::string prefix;
rcldb->dirlist(m_depth, prefix, thedirs); rcldb->dirlist(m_depth, prefix, thedirs);
LOGDEB0("IdxTreeModel::populate: prefix [" << prefix << "] thedirs: " <<
stringsToString(thedirs) << "\n");
const QModelIndex child = this->index(row, 0, index); const QModelIndex child = this->index(row, 0, index);
FsTreeWalker walker; FsTreeWalker walker;
WalkerCB cb(m_config, prefix == "/" ? std::string() : prefix, walker, this, child); WalkerCB cb(m_config, prefix == "/" ? std::string() : prefix, walker, this, child);
if (prefix.empty())
prefix = "/";
treelist(path_getfather(prefix), thedirs, cb); treelist(path_getfather(prefix), thedirs, cb);
#endif #endif
} }