--- linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp 2014/06/13 15:01:06 2630 +++ linuxsampler/trunk/src/engines/common/InstrumentScriptVM.cpp 2014/06/18 00:14:57 2645 @@ -60,11 +60,21 @@ handlerRelease = NULL; handlerController = NULL; pEvents = NULL; + for (int i = 0; i < 128; ++i) + pKeyEvents[i] = NULL; this->pEngineChannel = pEngineChannel; for (int i = 0; i < INSTR_SCRIPT_EVENT_GROUPS; ++i) eventGroups[i].setScript(this); } + InstrumentScript::~InstrumentScript() { + resetAll(); + if (pEvents) { + for (int i = 0; i < 128; ++i) delete pKeyEvents[i]; + delete pEvents; + } + } + /** @brief Load real-time instrument script. * * Loads the real-time instrument script given by @a text on the engine @@ -111,8 +121,11 @@ handlerExecCount++; // create script event pool (if it doesn't exist already) - if (!pEvents) + if (!pEvents) { pEvents = new Pool(CONFIG_MAX_EVENTS_PER_FRAGMENT); + for (int i = 0; i < 128; ++i) + pKeyEvents[i] = new RTList(pEvents); + } // create new VM execution contexts for new script while (!pEvents->poolIsEmpty()) {