Skip to content

Commit

Permalink
AutoTracking: fix memory watches triggering before connected
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Sep 10, 2024
1 parent 4ffcc80 commit 2380d41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/autotracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ class AutoTracker final : public LuaInterface<AutoTracker>{
return State::Unavailable;
}

bool isAnyConnected()
{
for (int index = 0; index < (int)_state.size(); ++index) {
if (getState(index) >= State::ConsoleConnected)
return true;
}
return false;
}

const std::string& getName(int index)
{
if (_ap && _backendIndex[_ap] == index) return BACKEND_AP_NAME;
Expand Down
3 changes: 3 additions & 0 deletions src/core/scripthost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ void ScriptHost::resetWatches()

void ScriptHost::runMemoryWatchCallbacks()
{
if (!_autoTracker || !_autoTracker->isAnyConnected())
return;

// we need to run callbacks because the autotracker changed some cache
// but really we only need to run the ones that are marked dirty
for (size_t i = 0; i < _memoryWatches.size(); i++) {
Expand Down

0 comments on commit 2380d41

Please sign in to comment.