From 8902c81b9ec5bb13c493df5d754a79bcdc77559d Mon Sep 17 00:00:00 2001 From: Pluto Date: Tue, 27 Sep 2022 01:34:18 +0000 Subject: [PATCH] =?UTF-8?q?!118=20fix:=20high=20CPU=20usage=20because=20fu?= =?UTF-8?q?tex=20is=20still=20waiting=20for=20queue=20after=20illegal=20ex?= =?UTF-8?q?it=20*=20fix=20*=20Merge=20remote-tracking=20branch=20'upstream?= =?UTF-8?q?/dev'=20into=20dev=20*=20fix:=20high=20CPU=20usage=20because=20?= =?UTF-8?q?futex=20is=20still=20waiting=20for=20queue=20after=20illegal=20?= =?UTF-8?q?exit=20*=20Merge=20remote-tracking=20branch=20'upstream/master'?= =?UTF-8?q?=20into=20dev=20*=20Merge=20remote-tracking=20branch=20'upstrea?= =?UTF-8?q?m/dev'=20into=20dev=20*=20feat:=20enable=20GPU=20*=20!113=203.2?= =?UTF-8?q?.1=20merge=20*=20!112=20Now=20stop=20use=20mail=20to=20collect?= =?UTF-8?q?=20info=20*=20Merge=20remote-tracking=20branch=20'upstream/dev'?= =?UTF-8?q?=20into=20dev=20*=20Merge=20branch=20'dev'=20of=20gitee.com:uni?= =?UTF-8?q?artisan2018/spark-store=20into=20dev=20*=20feat:=20=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E7=BD=91=E9=A1=B5=E7=BC=93=E5=AD=98=20*=20=E6=96=87?= =?UTF-8?q?=E6=A1=88=E4=BF=AE=E6=94=B9=20*=20update=20src/widget.ui.=20*?= =?UTF-8?q?=20feat:=20=E6=98=9F=E7=81=AB=E5=BA=94=E7=94=A8=E5=95=86?= =?UTF-8?q?=E5=BA=97=E6=A3=80=E6=B5=8B=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget.cpp | 41 +++++++++++++++++++++-------------------- src/widget.h | 1 + 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/widget.cpp b/src/widget.cpp index f0bb212..8e7d2eb 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -18,6 +18,7 @@ #include #include #include // 并发 +#include // close event #include #include @@ -572,14 +573,14 @@ void Widget::chooseLeftMenu(int index) updateUI(); - if(index <= 12) + if (index <= 12) { - if(themeIsDark) + if (themeIsDark) { QString darkurl = menuUrl[index].toString(); QStringList list = darkurl.split("/"); darkurl.clear(); - for(int i = 0; i < list.size() - 1; i++) + for (int i = 0; i < list.size() - 1; i++) { darkurl += list[i] + "/"; } @@ -687,22 +688,18 @@ void Widget::searchApp(QString text) } else { - // sendNotification(tr("Spark store could only process spk:// links for now. The search feature is coming soon!")); - // ui->webView->setUrl(QUrl("http://www.baidu.com/s?wd="+text)); // 这东西对接百度 - // ui->stackedWidget->setCurrentIndex(0); - // 禁止同时进行多次搜索 - if(!mutex.tryLock()) + if (!mutex.tryLock()) { return; } // 关键字搜索处理 httpClient->get("https://search.deepinos.org.cn/appinfo/search") - .header("content-type", "application/json") - .queryParam("keyword", text) - .onResponse([this](QByteArray result) - { + .header("content-type", "application/json") + .queryParam("keyword", text) + .onResponse([this](QByteArray result) + { auto json = QJsonDocument::fromJson(result).array(); if (json.empty()) { @@ -711,20 +708,24 @@ void Widget::searchApp(QString text) mutex.unlock(); return; } - displaySearchApp(json); - }) - .onError([this](QString errorStr) - { + displaySearchApp(json); }) + .onError([this](QString errorStr) + { qDebug() << "请求出错:" << errorStr; sendNotification(QString(tr("Request Error: %1")).arg(errorStr)); mutex.unlock(); - return; - }) - .timeout(10 * 1000) - .exec(); + return; }) + .timeout(10 * 1000) + .exec(); } } +void Widget::closeEvent(QCloseEvent *event) +{ + mutex.unlock(); + httpClient->deleteLater(); +} + /** * @brief 展示搜索的APP信息 */ diff --git a/src/widget.h b/src/widget.h index f9faad9..9ec716e 100644 --- a/src/widget.h +++ b/src/widget.h @@ -128,6 +128,7 @@ private: void setfoot(int); void updatefoot(); void updateUI(); + void closeEvent(QCloseEvent *event); quint64 dirFileSize(const QString &path);