master#296
Conversation
Johnson-zs
commented
May 22, 2026
- chore: bump version to 1.3.56
- fix: change search worker connection to direct
1.3.56 Log:
1. Modified the connection type between GenericSearchEngine and SearchWorker for cancel request from default to Qt::DirectConnection 2. This ensures immediate execution of cancel search operations instead of being queued in event loop Log: Improved search cancellation responsiveness Influence: 1. Test search cancellation in various scenarios 2. Verify immediate termination of search operations 3. Check for any potential threading issues with direct connection fix: 将搜索工作线程连接改为直接连接 1. 将GenericSearchEngine与SearchWorker之间的取消请求连接类型从默认改为 Qt::DirectConnection 2. 这确保了立即执行取消搜索操作而不是排队到事件循环中 Log: 改进了搜索取消的响应速度 Influence: 1. 在各种场景下测试搜索取消功能 2. 验证搜索操作是否能立即终止 3. 检查直接连接可能带来的线程问题
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
TAG Bot TAG: 1.3.56 |
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff记录。本次修改主要涉及两个文件:Debian changelog的版本更新,以及搜索引擎核心类中信号槽连接方式的修改。 下面我将从语法逻辑、代码质量、代码性能和代码安全四个维度对代码修改进行详细的审查,并提供改进意见。 1. 语法逻辑核心问题:跨线程使用 在 connect(this, &GenericSearchEngine::requestCancel,
m_worker, &SearchWorker::cancelSearch, Qt::DirectConnection);从上下文注释
2. 代码质量
3. 代码性能
4. 代码安全
💡 改进建议
🛠️ 推荐的代码修改方案方案一:恢复默认(最推荐) connect(this, &GenericSearchEngine::requestCancel,
m_worker, &SearchWorker::cancelSearch);
// 默认 Qt::AutoConnection,跨线程时自动变为 Qt::QueuedConnection,安全可靠方案二:使用原子变量 + 安全的内存屏障(如果嫌事件队列太慢) // SearchWorker.h
std::atomic<bool> m_isCanceled{false};
// SearchWorker.cpp
void SearchWorker::cancelSearch() {
m_isCanceled.store(true, std::memory_order_release);
}
void SearchWorker::doSearch() {
// ... 密集循环中检查
if (m_isCanceled.load(std::memory_order_acquire)) {
break; // 提前退出
}
}注意:即使采用此方案,信号槽连接依然建议保持默认的 方案三:使用 Qt 原生的中断机制 // 取消时
m_workerThread->requestInterruption();
// 工作线程的 doSearch 循环中
while(!QThread::currentThread()->isInterruptionRequested()) {
// 搜索逻辑
} |