diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-08-31 00:10:05 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-08-31 00:10:05 +0000 |
| commit | 3ccf7415c88dabce1c2efeb79d7a3daf3a7a8dba (patch) | |
| tree | fc649519f0360786a78f3b4e13c1174df50bfe49 /lib/actions/action.cpp | |
| parent | 7581b23a6bc4823981e973c2cfcc33fbed171122 (diff) | |
| download | enigma2-3ccf7415c88dabce1c2efeb79d7a3daf3a7a8dba.tar.gz enigma2-3ccf7415c88dabce1c2efeb79d7a3daf3a7a8dba.zip | |
- fix actions bug: iterator could become corrupted
Diffstat (limited to 'lib/actions/action.cpp')
| -rw-r--r-- | lib/actions/action.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/actions/action.cpp b/lib/actions/action.cpp index 25db199e..494c252d 100644 --- a/lib/actions/action.cpp +++ b/lib/actions/action.cpp @@ -126,6 +126,8 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st void eActionMap::keyPressed(int device, int key, int flags) { + std::list<std::pair<PyObject*,PyObject*> > call_list; + /* iterate active contexts. */ for (std::multimap<int,eActionBinding>::const_iterator c(m_bindings.begin()); c != m_bindings.end();) { @@ -177,8 +179,8 @@ void eActionMap::keyPressed(int device, int key, int flags) PyTuple_SetItem(pArgs, 0, PyString_FromString(k->first.c_str())); PyTuple_SetItem(pArgs, 1, PyString_FromString(k->second.m_action.c_str())); ++k; - ePython::call(i->second.m_fnc, pArgs); - Py_DECREF(pArgs); + Py_INCREF(i->second.m_fnc); + call_list.push_back(std::pair<PyObject*,PyObject*>(i->second.m_fnc, pArgs)); } else ++k; } @@ -187,11 +189,18 @@ void eActionMap::keyPressed(int device, int key, int flags) PyObject *pArgs = PyTuple_New(2); PyTuple_SetItem(pArgs, 0, PyInt_FromLong(key)); PyTuple_SetItem(pArgs, 1, PyInt_FromLong(flags)); - ePython::call(i->second.m_fnc, pArgs); - Py_DECREF(pArgs); + Py_INCREF(i->second.m_fnc); + call_list.push_back(std::pair<PyObject*,PyObject*>(i->second.m_fnc, pArgs)); } } } + + for (std::list<std::pair<PyObject*,PyObject*> >::iterator i(call_list.begin()); i != call_list.end(); ++i) + { + ePython::call(i->first, i->second); + Py_DECREF(i->first); + Py_DECREF(i->second); + } } eAutoInitPtr<eActionMap> init_eActionMap(eAutoInitNumbers::actions, "eActionMap"); |
