mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-08 02:07:20 -05:00
Fix "Date" condition returning true unexpectedly
This could happen if the plugin was stopped on the General tab and restarted or the first time the plugin was started.
This commit is contained in:
parent
bc0497d2c9
commit
63a545b293
|
|
@ -111,10 +111,10 @@ bool MacroWasPausedSince(
|
|||
|
||||
bool MacroWasCheckedSinceLastStart(Macro *macro)
|
||||
{
|
||||
return macro ? macro->LastConditionCheckTime()
|
||||
.time_since_epoch()
|
||||
.count() != 0
|
||||
: false;
|
||||
if (!macro) {
|
||||
return false;
|
||||
}
|
||||
return macro->LastConditionCheckTime().time_since_epoch().count() != 0;
|
||||
}
|
||||
|
||||
void AddMacroHelperThread(Macro *macro, std::thread &&newThread)
|
||||
|
|
|
|||
|
|
@ -176,15 +176,21 @@ bool MacroConditionDate::CheckRegularDate(int64_t msSinceLastCheck)
|
|||
|
||||
bool MacroConditionDate::CheckCondition()
|
||||
{
|
||||
auto m = GetMacro();
|
||||
if (!m) {
|
||||
auto macro = GetMacro();
|
||||
if (!macro) {
|
||||
return false;
|
||||
}
|
||||
const auto timePassed = std::chrono::high_resolution_clock::now() -
|
||||
LastMacroConditionCheckTime(m);
|
||||
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
const auto lastCheck = LastMacroConditionCheckTime(macro);
|
||||
|
||||
const auto timePassed = now - lastCheck;
|
||||
|
||||
const auto msSinceLastCheck =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
timePassed);
|
||||
MacroWasCheckedSinceLastStart(macro)
|
||||
? std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
timePassed)
|
||||
: std::chrono::milliseconds(0);
|
||||
|
||||
if (_dayOfWeekCheck) {
|
||||
return CheckDayOfWeek(msSinceLastCheck.count());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user