@@ -166,13 +166,15 @@ inline std::string EventTypeToString(EVENT_TYPES e) { return std::string(magic_e
166
166
167
167
// 调用事件监听函数,拦截返回RETURN_VALUE
168
168
#define CallEventRtnValue (TYPE, RETURN_VALUE, ...) \
169
- std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
170
- bool isCancelled; \
169
+ std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
170
+ bool isCancelled = false ; \
171
171
for (auto & listener : nowList) { \
172
172
EngineScope enter (listener.engine ); \
173
173
try { \
174
174
auto result = listener.func .get ().call ({}, __VA_ARGS__); \
175
- if (result.isBoolean () && result.asBoolean ().value () == false ) isCancelled = true ; \
175
+ if (result.isBoolean () && result.asBoolean ().value () == false ) { \
176
+ isCancelled = true ; \
177
+ } \
176
178
} \
177
179
LISTENER_CATCH (TYPE) \
178
180
} \
@@ -182,13 +184,15 @@ inline std::string EventTypeToString(EVENT_TYPES e) { return std::string(magic_e
182
184
183
185
// 调用事件监听函数,拦截返回
184
186
#define CallEventVoid (TYPE, ...) \
185
- std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
186
- bool isCancelled; \
187
+ std::list<ListenerListType>& nowList = listenerList[int (TYPE)]; \
188
+ bool isCancelled = false ; \
187
189
for (auto & listener : nowList) { \
188
190
EngineScope enter (listener.engine ); \
189
191
try { \
190
192
auto result = listener.func .get ().call ({}, __VA_ARGS__); \
191
- if (result.isBoolean () && result.asBoolean ().value () == false ) isCancelled = true ; \
193
+ if (result.isBoolean () && result.asBoolean ().value () == false ) { \
194
+ isCancelled = true ; \
195
+ } \
192
196
} \
193
197
LISTENER_CATCH (TYPE) \
194
198
} \
0 commit comments