When I created the bitcoin-qt GUI I made a big mistake in its design. I copied this more or less exactly from the wxwindows GUI. I was aware of this back in the day, but was planning to fix it later. I never got around to it. Honestly speaking I don’t think I ever will.
In any case, the event loop in the main thread of a Qt program (or any GUI program, for that matter) is never supposed to block. Any operation that can take non-trivial time (even in the order of 40ms) should be executed asynchronously.
We have many such cases; not only when the user does an explicit operation such as send, but also in response to internal notiications, and automatic periodic polls for new transactions, the current balance, and so on (these can take longer due to cs_main
lock contention: worst during initial sync and when catching up). Also at the start of the application. Pretty much all communication with the node and wallet happens in the GUI thread itself.
This is more “redesign” than “refactor”, anyhow, and definitely not a “good first issue” it needs to happen at some point. Even more if we want snazzy animations in the android GUI.
(ref #17112 and plenty of other “GUI not responding” issues)