From 2905b8c89eb7219853f2a50cc962c4f1d84b89b2 Mon Sep 17 00:00:00 2001 From: Yue-Lan Date: Thu, 14 Sep 2023 14:21:04 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20#191467=20=E3=80=90=E8=93=9D=E7=89=99?= =?UTF-8?q?=E3=80=91=E8=93=9D=E7=89=99=E6=96=87=E4=BB=B6=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95-=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit note: 文件操作层会设置QApplication是否在关闭所有窗口时退出,这个流程不应该影响peony以外的应用 --- .../file-operation/file-operation-manager.cpp | 32 +++++++++---------- src/peony-main.cpp | 1 + 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libpeony-qt/file-operation/file-operation-manager.cpp b/libpeony-qt/file-operation/file-operation-manager.cpp index f69a9f24..b4243cd1 100755 --- a/libpeony-qt/file-operation/file-operation-manager.cpp +++ b/libpeony-qt/file-operation/file-operation-manager.cpp @@ -316,32 +316,32 @@ void FileOperationManager::startOperation(FileOperation *operation, bool addToHi } start: - + static bool oldQuitOnLastWindow = QApplication::quitOnLastWindowClosed(); QApplication::setQuitOnLastWindowClosed(false); connect(operation, &FileOperation::operationFinished, this, [=]() { operation->notifyFileWatcherOperationFinished(); - auto settings = GlobalSettings::getInstance(); - bool runbackend = settings->getInstance()->getValue(RESIDENT_IN_BACKEND).toBool(); - QApplication::setQuitOnLastWindowClosed(!runbackend); - - QTimer::singleShot(1000, this, [=]() { - int last_op_count = m_thread_pool->children().count(); - if (last_op_count == 0) { - if (qApp->allWidgets().isEmpty()) { - if (!runbackend) { - qApp->quit(); + if (qApp->property("isPeony").toBool()) { + auto settings = GlobalSettings::getInstance(); + bool runbackend = settings->getInstance()->getValue(RESIDENT_IN_BACKEND).toBool(); + QApplication::setQuitOnLastWindowClosed(!runbackend); + QTimer::singleShot(1000, this, [=]() { + int last_op_count = m_thread_pool->children().count(); + if (last_op_count == 0) { + if (qApp->allWidgets().isEmpty()) { + if (!runbackend) { + qApp->quit(); + } } } - } - }); + }); + } else { + QApplication::setQuitOnLastWindowClosed(oldQuitOnLastWindow); + } }, Qt::BlockingQueuedConnection); - - bool allowParallel = m_allow_parallel; - connect(operation, &FileOperation::operationTotalFileSize, this, [=](const qint64& total_file_size) { // fix #171449 if (m_progressbar->isHidden()) { diff --git a/src/peony-main.cpp b/src/peony-main.cpp index fce277c7..dcb56cce 100644 --- a/src/peony-main.cpp +++ b/src/peony-main.cpp @@ -110,6 +110,7 @@ int main(int argc, char *argv[]) } PeonyApplication app(argc, argv, "peony-qt"); + qApp->setProperty("isPeony", true); Peony::XdgPortalHelper::getInstance()->tryResetPortal(); if (app.isSecondary()) return 0;