Add lock in deconstruction of index-generator.

This commit is contained in:
zhangpengfei 2021-01-11 18:36:04 +08:00
parent 8ad3dffc78
commit 18665ec2cd
2 changed files with 6 additions and 4 deletions

View File

@ -22,10 +22,6 @@ FileSearcher::~FileSearcher()
void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResultFile,QQueue<QString> *searchResultDir,QQueue<QPair<QString,QStringList>> *searchResultContent)
{
m_search_result_file = searchResultFile;
m_search_result_dir = searchResultDir;
m_search_result_content = searchResultContent;
m_mutex1.lock();
++uniqueSymbol1;
m_mutex1.unlock();
@ -35,6 +31,11 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResult
m_mutex3.lock();
++uniqueSymbol3;
m_mutex3.unlock();
m_search_result_file = searchResultFile;
m_search_result_dir = searchResultDir;
m_search_result_content = searchResultContent;
//file
QtConcurrent::run([&, uniqueSymbol1](){
if(!m_search_result_file->isEmpty())

View File

@ -120,6 +120,7 @@ IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent)
IndexGenerator::~IndexGenerator()
{
QMutexLocker locker(&m_mutex);
qDebug() << "~IndexGenerator";
if(m_datebase_path)
delete m_datebase_path;