Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date #1255

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/macro/macro-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ bool MacroWasPausedSince(
return macro ? macro->WasPausedSince(time) : false;
}

bool MacroWasCheckedSinceLastStart(Macro *macro)
{
if (!macro) {
return false;
}
return macro->LastConditionCheckTime().time_since_epoch().count() != 0;
}

void AddMacroHelperThread(Macro *macro, std::thread &&newThread)
{
if (!macro) {
Expand Down
1 change: 1 addition & 0 deletions lib/macro/macro-helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ EXPORT bool MacroIsPaused(Macro *);
EXPORT bool
MacroWasPausedSince(Macro *,
const std::chrono::high_resolution_clock::time_point &);
EXPORT bool MacroWasCheckedSinceLastStart(Macro *);

EXPORT void AddMacroHelperThread(Macro *, std::thread &&);

Expand Down
16 changes: 6 additions & 10 deletions plugins/base/macro-action-systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,23 @@ MacroActionSystrayEdit::MacroActionSystrayEdit(

void MacroActionSystrayEdit::TitleChanged()
{
if (_loading || !_entryData) {
return;
}

auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_title = _title->text().toStdString();
}

void MacroActionSystrayEdit::IconPathChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}

auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_iconPath = text.toStdString();
}

void MacroActionSystrayEdit::CheckIfTrayIsDisabled()
{
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(31, 0, 0)
auto config = obs_frontend_get_user_config();
#else
auto config = obs_frontend_get_global_config();
#endif
if (!config) {
return;
}
Expand Down
18 changes: 12 additions & 6 deletions plugins/base/macro-condition-date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading