Merge pull request #65 from iaom/0110-dev

Add lock in deconstruction of index-generator.
This commit is contained in:
张佳萍 2021-01-11 18:43:21 +08:00 committed by GitHub
commit f0984c5a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) 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(); m_mutex1.lock();
++uniqueSymbol1; ++uniqueSymbol1;
m_mutex1.unlock(); m_mutex1.unlock();
@ -35,6 +31,11 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResult
m_mutex3.lock(); m_mutex3.lock();
++uniqueSymbol3; ++uniqueSymbol3;
m_mutex3.unlock(); m_mutex3.unlock();
m_search_result_file = searchResultFile;
m_search_result_dir = searchResultDir;
m_search_result_content = searchResultContent;
//file //file
QtConcurrent::run([&, uniqueSymbol1](){ QtConcurrent::run([&, uniqueSymbol1](){
if(!m_search_result_file->isEmpty()) if(!m_search_result_file->isEmpty())

View File

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