Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The TypeScript control.onEvent() flags argument is not passed to the DAL/CODAL event listener #5709

Closed
microbit-carlos opened this issue Jun 18, 2024 · 2 comments · Fixed by #5750
Assignees
Labels

Comments

@microbit-carlos
Copy link
Collaborator

The control.onEvent() C++ function checks if any flag is provided, and if not it set the EventFlags::QueueIfBusy by default:

void onEvent(int src, int value, Action handler, int flags = 0) {
if (!flags) flags = ::EventFlags::QueueIfBusy;
registerWithDal(src, value, handler, (int)flags);
}

However, the registerWithDal() function then ignores the flags argument:

void registerWithDal(int id, int event, Action a, int flags) {
uBit.messageBus.ignore(id, event, dispatchForeground);
uBit.messageBus.listen(id, event, dispatchForeground, a);
incr(a);
registerGCPtr(a);
}

So, it ultimately depends on the CODAL default beings set to MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY via the EVENT_LISTENER_DEFAULT_FLAGS config:

@abchatra
Copy link
Collaborator

@microbit-carlos what is the impact of this bug?

@abchatra abchatra added this to the Microbit Yearly release milestone Jul 26, 2024
@microbit-carlos
Copy link
Collaborator Author

microbit-carlos commented Jul 26, 2024

We are working around it in the extension by creating a custom onEvent TS function that calls a custom registerWithDal C++ function that passes the extra argument to uBit.messageBus.listen(). So it's not a blocker, but I would consider this a bug in pxt-microbit, as it's only missing passing the flags argument forward.

- uBit.messageBus.listen(id, event, dispatchForeground, a); 
+ uBit.messageBus.listen(id, event, dispatchForeground, a, flags); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants