stevengharris/MarkupEditor

Race condition during table insertion

stevengharris opened this issue · 1 comments

Discussed in #141

Originally posted by sundancecloud September 21, 2023
Hi,

On Mac Catalyst, when dragging to insert a table:

After letting the mouse button up, the "onEnded" handler is invoked and the rows&cols are picked up for table creation. This is all good.

However, because the mouse for a brief moment is still over the popup, the "onHover" handler is also invoked. This promptly sets rows&cols to 0.

The race condition is that onEnded may or may not be serviced before onHover. If onHover is invoked first the rows&cols are set to zero .... and then onEnded is serviced, but then no table of 0x0 will be created.

A proposed fix, is to modify the onHover() handler:

// Don't clear if a drag has just happened.
if !dragged {
       rows = 0
       cols = 0
 }

On a side note, I would like to thank Steven for this great piece of software!

I didn't realize moving a discussion to an issue would not move the entire thread! Anyway, just to keep the reply to @sundancecloud:

Thank you for raising the issue with all these details. I'm moving this to the Issues area and will try to reproduce and fold-in the fix soon. And thanks for the kind words :-).