MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / DeleteTimer

Method DeleteTimer

source/script.cpp:4120–4147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4118
4119
4120void Script::DeleteTimer(IObject *aLabel)
4121{
4122 ScriptTimer *timer, *previous = NULL;
4123 for (timer = mFirstTimer; timer != NULL; previous = timer, timer = timer->mNextTimer)
4124 if (timer->mCallback == aLabel) // Match found.
4125 {
4126 // Disable it, even if it's not technically being deleted yet.
4127 if (timer->mEnabled)
4128 timer->Disable(); // Keeps track of mTimerEnabledCount and whether the main timer is needed.
4129 if (timer->mExistingThreads) // This condition differs from g->CurrentTimer == timer, which only detects the "top-most" timer.
4130 {
4131 // In this case we can't delete the timer yet, but CheckScriptTimers()
4132 // will check mEnabled after the callback returns and will delete it then.
4133 break;
4134 }
4135 // Remove it from the list.
4136 if (previous)
4137 previous->mNextTimer = timer->mNextTimer;
4138 else
4139 mFirstTimer = timer->mNextTimer;
4140 if (mLastTimer == timer)
4141 mLastTimer = previous;
4142 mTimerCount--;
4143 // Delete the timer, automatically releasing its reference to the object.
4144 delete timer;
4145 break;
4146 }
4147}
4148
4149
4150

Callers 2

BIF_DECLFunction · 0.80
CheckScriptTimersFunction · 0.80

Calls 1

DisableMethod · 0.45

Tested by

no test coverage detected