From 5cea429fc6c650e44a50bbee720be6fd4685adf3 Mon Sep 17 00:00:00 2001 From: Tsubasa6848 <116721335+Tsubasa6848@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:53:20 +0800 Subject: [PATCH] fix: fix reload command --- src/Features/CleanTask.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Features/CleanTask.cpp b/src/Features/CleanTask.cpp index 0067a8f..f775fcb 100644 --- a/src/Features/CleanTask.cpp +++ b/src/Features/CleanTask.cpp @@ -11,9 +11,9 @@ bool mSendToast = true; namespace Cleaner { -static std::shared_ptr> mAutoCleanTask; -static std::shared_ptr> mCleanTaskCount; -static std::shared_ptr> mCleanTaskTPS; +static std::shared_ptr> mAutoCleanTask = nullptr; +static std::shared_ptr> mCleanTaskCount = nullptr; +static std::shared_ptr> mCleanTaskTPS = nullptr; ServerTimeScheduler scheduler; @@ -107,9 +107,17 @@ void CleanTaskTPS(float min_tps) { } void stopAllTasks() { - mCleanTaskTPS->cancel(); - mCleanTaskCount->cancel(); - mAutoCleanTask->cancel(); + if (!mCleanTaskCount) { + mCleanTaskTPS->cancel(); + scheduler.remove(mCleanTaskTPS); + } + if (mCleanTaskCount) { + mCleanTaskCount->cancel(); + scheduler.remove(mCleanTaskCount); + } + if (mAutoCleanTask) { + mAutoCleanTask->cancel(); + scheduler.remove(mAutoCleanTask); + } } - } // namespace Cleaner