Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -391,9 +391,13 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func · 390 unmodified lines | |||
| 391 | 391 | ||
| 392 | // Look up the handler associated with eventName and entityID. If found, evalute the argGenerator thunk and call the handler with those args | 392 | // Look up the handler associated with eventName and entityID. If found, evalute the argGenerator thunk and call the handler with those args |
| 393 | void ScriptEngine::generalHandler(const EntityItemID& entityID, const QString& eventName, std::function<QScriptValueList()> argGenerator) { | 393 | void ScriptEngine::generalHandler(const EntityItemID& entityID, const QString& eventName, std::function<QScriptValueList()> argGenerator) { |
| 394 | if (!_registeredHandlers.contains(entityID)) return; | 394 | if (!_registeredHandlers.contains(entityID)) { |
| 395 | return; | ||
| 396 | } | ||
| 395 | const RegisteredEventHandlers& handlersOnEntity = _registeredHandlers[entityID]; | 397 | const RegisteredEventHandlers& handlersOnEntity = _registeredHandlers[entityID]; |
| 396 | if (!handlersOnEntity.contains(eventName)) return; | 398 | if (!handlersOnEntity.contains(eventName)) { |
| 399 | return; | ||
| 400 | } | ||
| 397 | QScriptValueList handlersForEvent = handlersOnEntity[eventName]; | 401 | QScriptValueList handlersForEvent = handlersOnEntity[eventName]; |
| 398 | if (!handlersForEvent.isEmpty()) { | 402 | if (!handlersForEvent.isEmpty()) { |
| 399 | QScriptValueList args = argGenerator(); | 403 | QScriptValueList args = argGenerator(); |
| @@ -404,7 +408,9 @@ void ScriptEngine::generalHandler(const EntityItemID& entityID, const QString& e · 4 unmodified lines | |||
| 404 | } | 408 | } |
| 405 | // Unregister the handlers for this eventName and entityID. | 409 | // Unregister the handlers for this eventName and entityID. |
| 406 | void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) { | 410 | void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) { |
| 407 | if (!_registeredHandlers.contains(entityID)) return; | 411 | if (!_registeredHandlers.contains(entityID)) { |
| 412 | return; | ||
| 413 | } | ||
| 408 | RegisteredEventHandlers& handlersOnEntity = _registeredHandlers[entityID]; | 414 | RegisteredEventHandlers& handlersOnEntity = _registeredHandlers[entityID]; |
| 409 | QScriptValueList& handlersForEvent = handlersOnEntity[eventName]; | 415 | QScriptValueList& handlersForEvent = handlersOnEntity[eventName]; |
| 410 | // QScriptValue does not have operator==(), so we can't use QList::removeOne and friends. So iterate. | 416 | // QScriptValue does not have operator==(), so we can't use QList::removeOne and friends. So iterate. |