From e758f9e03ddbe348c1fa2bccd69ded2cb6b29230 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Wed, 13 Jan 2021 15:04:37 +0800 Subject: [PATCH] fix(thread): Search result is incorrect because of thread quit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复由于线程退出导致的搜索结果错误问题 Log: 修复由于线程退出导致的搜索结果错误问题 Bug: -- --- src/search-result.cpp | 4 +-- .../qt-single-application.cpp | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/search-result.cpp b/src/search-result.cpp index c3a74b4..13f6170 100644 --- a/src/search-result.cpp +++ b/src/search-result.cpp @@ -22,9 +22,9 @@ SearchResult::~SearchResult() void SearchResult::run() { QTimer * m_timer = new QTimer; + m_timer->setInterval(3000); int emptyLists = 0; while(!isInterruptionRequested()) { - qWarning()<<"--------------------"; emptyLists = 0; m_mainwindow->m_searcher->m_mutex1.lock(); if (!m_mainwindow->m_search_result_file->isEmpty()) { @@ -44,7 +44,7 @@ void SearchResult::run() } m_mainwindow->m_searcher->m_mutex3.lock(); if (!m_mainwindow->m_search_result_content->isEmpty()) - qDebug() << m_mainwindow->m_search_result_content->head(); +// qDebug() << m_mainwindow->m_search_result_content->head(); if (!m_mainwindow->m_search_result_content->isEmpty()) { Q_EMIT this->searchResultContent(m_mainwindow->m_search_result_content->dequeue()); m_mainwindow->m_searcher->m_mutex3.unlock(); diff --git a/src/singleapplication/qt-single-application.cpp b/src/singleapplication/qt-single-application.cpp index 255d91a..02c5699 100644 --- a/src/singleapplication/qt-single-application.cpp +++ b/src/singleapplication/qt-single-application.cpp @@ -327,23 +327,24 @@ QWidget* QtSingleApplication::activationWindow() const */ void QtSingleApplication::activateWindow() { - if (actWin) { - if(this->applicationState() & Qt::ApplicationInactive) - { - MainWindow* w=qobject_cast(actWin); -// w->loadMainWindow(); - w->clearSearchResult(); - actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); - actWin->raise(); - actWin->showNormal(); - actWin->activateWindow(); - } - else { - actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); - actWin->hide(); - } + //单例置顶策略,由于bootOptionsFilter in mainwindow自带置顶策略,故注掉此处 +// if (actWin) { +// if(this->applicationState() & Qt::ApplicationInactive) +// { +// MainWindow* w=qobject_cast(actWin); +//// w->loadMainWindow(); +// w->clearSearchResult(); +// actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); +// actWin->raise(); +// actWin->showNormal(); +// actWin->activateWindow(); +// } +// else { +// actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); +// actWin->hide(); +// } - } +// } }