@@ -246,6 +246,10 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
246246
247247 if ((stat == ES_NOT_HANDLED || stat == ES_PASS) && m_externals != nil)
248248 {
249+ // TODO[19681]: This can be removed when all engine messages are sent with
250+ // target.
251+ bool t_target_was_valid = MCtargetptr.IsValid ();
252+
249253 Exec_stat oldstat = stat;
250254 stat = m_externals -> Handle (this , htype, mess, params);
251255
@@ -259,7 +263,7 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
259263
260264 if (stat == ES_PASS || stat == ES_NOT_HANDLED)
261265 {
262- if (!MCtargetptr.IsValid ())
266+ if (t_target_was_valid && !MCtargetptr.IsValid ())
263267 {
264268 stat = ES_NORMAL;
265269 t_has_passed = false ;
@@ -292,12 +296,16 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
292296
293297 if ((stat == ES_NOT_HANDLED || stat == ES_PASS))
294298 {
299+ // TODO[19681]: This can be removed when all engine messages are sent with
300+ // target.
301+ bool t_target_was_valid = MCtargetptr.IsValid ();
302+
295303 extern Exec_stat MCEngineHandleLibraryMessage (MCNameRef name, MCParameter *params);
296304 stat = MCEngineHandleLibraryMessage (mess, params);
297305
298306 if (stat == ES_PASS || stat == ES_NOT_HANDLED)
299307 {
300- if (!MCtargetptr.IsValid ())
308+ if (t_target_was_valid && !MCtargetptr.IsValid ())
301309 {
302310 stat = ES_NORMAL;
303311 t_has_passed = false ;
0 commit comments