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