Movewindow function transiently disappears during unrelated WindowAddHotspot

Posted by Fiendish on Sat 12 Mar 2022 06:50 AM — 7 posts, 24,898 views.

USA Global Moderator #0
I have a bit of a strange situation that I can reproduce 100% in situ, but so far I have not managed to make a minimal test case.

This is what happens...

The player makes a miniwindow in the world script space with a movewindow drag handler on it. The player then drags the window around for a while over top of their GMCP mapper miniwindow which of course lives in its own plugin. If new room GMCP data arrives (like if they set a timer to send the "look" command) causing the mapper to refresh its display, the miniwindow they're dragging suddenly AND TEMPORARILY forgets that its mouse handler functions exist and this error message pops up saying:

Quote:
Cannot find the function 'mw_testwindow_movewindow_info.dragmove' - item 'dragmove' is nil


https://i.imgur.com/Cz0503w.png

After clicking "Ok" to dismiss the error message, the miniwindow that was being dragged stays stuck to the mouse cursor, following it around until the mouse is clicked again. After that, the miniwindow's dragmove handler resumes working normally until the next time.

The problem goes away if I comment out this WindowAddHotspot call inside the mapper https://github.com/fiendish/aardwolfclientpackage/blob/c6441b3c36e58ca79ef2029292e8012d86a4e9f7/MUSHclient/lua/aardmapper.lua#L919-L924

I've ruled out my Lua DLL by making some necessary modifications to be able to load the Aardwolf mapper plugin without LuaJIT and dropping in the classic one, so that's not the problem.

I think the problem also doesn't occur if the dragged miniwindow is larger than the mapper miniwindow, so it may be some global optimization gone bad using the hotspot corner coordinates when adding hotspots to miniwindows?

Anyway, there appears to be _something_ about that WindowAddHotspot call that is transiently botching an entirely unrelated script's miniwindow's ability to remember its dragmove function.
Amended on Sun 13 Mar 2022 10:59 PM by Fiendish
Australia Forum Administrator #1
Quote:

causing the mapper to refresh its display


Does the mapper remove all hotspots while refreshing the display?
USA Global Moderator #2
It would remove all of its own, yes. 99% of all hotspots on the mapper are individual rooms which are getting drawn from scratch when new room info arrives.
Amended on Wed 16 Mar 2022 02:18 AM by Fiendish
Australia Forum Administrator #3

So the miniwindow which is not being refreshed suddenly “forgets” about the mouse-down action?

Amended on Wed 16 Mar 2022 05:20 AM by Nick Gammon
USA Global Moderator #4
Yeah. Mid-drag, the drag handler function that it was using just nanoseconds prior is suddenly set to nil, causing an error, and then is immediately restored after dismissing said error.

I did say it was a strange situation. :)
Amended on Wed 16 Mar 2022 06:27 AM by Fiendish
USA Global Moderator #5
Commenting out this block makes the problem go away.
https://github.com/nickgammon/mushclient/blob/059aa23f76a099f9b826eae873a79a2a81859ffd/scripting/methods/methods_miniwindows.cpp#L580-L599

I suspect that inducing a move on a newly created hotspot should only happen if the mouse is not already bound to dragging another hotspot.
USA Global Moderator #6
So maybe https://github.com/nickgammon/mushclient/pull/69