Whoops, some issues with deleting timers.

This commit is contained in:
John McCardle 2024-03-07 09:49:24 -05:00
commit d417bdc8a3
3 changed files with 5 additions and 21 deletions

View file

@ -72,12 +72,13 @@ void GameEngine::run()
void GameEngine::manageTimer(std::string name, PyObject* target, int interval)
{
//std::cout << "Manage timer called. " << name << " " << interval << std::endl;
if (timers.find(name) != timers.end()) // overwrite existing
auto it = timers.find(name);
if (it != timers.end()) // overwrite existing
{
if (target == NULL || target == Py_None) // delete
{
Py_DECREF(target);
timers.erase(name);
Py_DECREF(timers[name].target);
timers.erase(it);
return;
}
}