From ba52540c4ea6e0fd67bf9008d2d3a3eaba9e2782 Mon Sep 17 00:00:00 2001 From: iaom Date: Wed, 14 Jun 2023 14:08:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BD=93=E6=90=9C=E7=B4=A2UI?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=90=8E=E6=9C=AA=E6=AD=A3=E7=A1=AE=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E6=8F=92=E4=BB=B6=E6=90=9C=E7=B4=A2=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98;=E8=A7=A3=E5=86=B3=E9=81=8D?= =?UTF-8?q?=E5=8E=86=E6=90=9C=E7=B4=A2=E6=97=B6=E6=96=87=E4=BB=B6=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=8F=92=E4=BB=B6=E9=95=BF=E6=97=B6=E9=97=B4cpu?= =?UTF-8?q?=E5=8D=A0=E7=94=A8=E8=BE=83=E9=AB=98=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/model/search-result-manager.cpp | 6 ++--- libsearch/index/search-manager.cpp | 32 ++++++++---------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/frontend/model/search-result-manager.cpp b/frontend/model/search-result-manager.cpp index b0811f8..9358f37 100644 --- a/frontend/model/search-result-manager.cpp +++ b/frontend/model/search-result-manager.cpp @@ -48,10 +48,10 @@ void SearchResultManager::stopSearch() { if(m_getResultThread->isRunning()) { m_getResultThread->stop(); - SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId); - plugin->stopSearch(); - qDebug() << m_pluginId << "stopped"; } + SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId); + plugin->stopSearch(); + qDebug() << m_pluginId << "stopped"; } void SearchResultManager::initConnections() diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index 8bd60c2..a92bf47 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -541,7 +541,14 @@ void DirectSearch::run() { } bfs.enqueue(i.absoluteFilePath()); } - match(i); + SearchManager::m_mutexDir.lock(); + if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) { + match(i); + SearchManager::m_mutexDir.unlock(); + } else { + SearchManager::m_mutexDir.unlock(); + return; + } } } } @@ -549,29 +556,10 @@ void DirectSearch::run() { void DirectSearch::match(const QFileInfo &info) { if(info.fileName().contains(m_keyword, Qt::CaseInsensitive)) { - if((info.isDir() && m_value == DIR_SEARCH_VALUE)) { + if((info.isDir() && m_value == DIR_SEARCH_VALUE) || (info.isFile() && m_value == FILE_SEARCH_VALUE)) { SearchPluginIface::ResultInfo ri; if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) { - SearchManager::m_mutexDir.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbolDir) { - m_searchResult->enqueue(ri); - SearchManager::m_mutexDir.unlock(); - } else { - SearchManager::m_mutexDir.unlock(); - return; - } - } - } else if (info.isFile() && m_value == FILE_SEARCH_VALUE) { - SearchPluginIface::ResultInfo ri; - if(SearchManager::creatResultInfo(ri,info.absoluteFilePath())) { - SearchManager::m_mutexFile.lock(); - if(m_uniqueSymbol == SearchManager::uniqueSymbolFile) { - m_searchResult->enqueue(ri); - SearchManager::m_mutexFile.unlock(); - } else { - SearchManager::m_mutexFile.unlock(); - return; - } + m_searchResult->enqueue(ri); } } }