Whoops, some issues with deleting timers.
This commit is contained in:
parent
ccd79fc551
commit
d417bdc8a3
3 changed files with 5 additions and 21 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue