Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gspencergoog
Copy link
Contributor

Description

This PR makes the Linux key handling code a little more lenient when it comes to the order in which it receives responses to key events from the framework. I had assumed that there wasn't a case where responses could get out of order, but it seems that it is possible, given that you can mash on the keyboard and eventually get one out of order.

This changes the code so that instead of just looking at the first entry in the pending event deque, it searches the deque starting at the beginning to find the event, and remove it.

Related Issues

Tests

  • I am not sure how to test this yet, working on that (which is why this is still draft)

@google-cla google-cla bot added the cla: yes label Jan 7, 2021
@gspencergoog gspencergoog marked this pull request as ready for review January 7, 2021 22:32
@gspencergoog gspencergoog requested a review from dkwingsmt January 7, 2021 22:32
Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dkwingsmt
Copy link
Contributor

Does this happen to other platforms as well?

@gspencergoog
Copy link
Contributor Author

Yes, Windows did (but I already fixed that in my pending PR), and Android needs a similar fix, which I'll work on today.

@gspencergoog gspencergoog merged commit 9cb4d2d into flutter:master Jan 8, 2021
@gspencergoog gspencergoog deleted the linux_lenient_keys branch January 8, 2021 18:44
@gspencergoog
Copy link
Contributor Author

@dkwingsmt I mean, actually, I haven't seen this same problem on other platforms, but I'm going to proactively fix the algorithm that the others are using (macOS doesn't use the same algorithm) to not assume that order is always preserved.

for (guint i = 0; i <= self->pending_events->len; ++i) {
if (FL_KEY_EVENT_PAIR(g_ptr_array_index(self->pending_events, i))->id ==
id) {
return FL_KEY_EVENT_PAIR(g_ptr_array_index(self->pending_events, 0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're testing against index i, but then still returning index 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding that. I'll submit a fix today.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextField on Flutter for Desktop Linux is crashing after some input

4 participants