websocket: event loop names and thread/evloop pairs are set in BaseUI::main_thread()

There is no thread when an AbstractUI<T> is constructed. The event loop name and the
association between the event loop object and the thread that "runs" it must be
set from within the thread, which is not created until BaseUI::run() is called.

There appears to have been some confusion in e3569b64 about how this
all works; this commit should remove that
This commit is contained in:
Paul Davis 2023-10-24 16:26:50 -06:00
parent 94fec7fd8a
commit f34ce17bf0

View File

@ -102,21 +102,10 @@ struct PluginParamValueObserver {
FeedbackHelperUI::FeedbackHelperUI()
: AbstractUI<BaseUI::BaseRequestObject> ("WS_FeedbackHelperUI")
{
// This renames and changes the event loop for the main thread, presumably
// this is not the actually desired behavior.
char name[64];
snprintf (name, 64, "WS-%p", (void*)DEBUG_THREAD_SELF);
pthread_set_name (name);
/* The event loop needs to be restored when FeedbackHelperUI is destroyed,
* otherwise future access will result in a crash (heap-use-after-free).
*/
_main_event_loop = get_event_loop_for_thread ();
set_event_loop_for_thread (this);
}
FeedbackHelperUI::~FeedbackHelperUI ()
{
set_event_loop_for_thread (_main_event_loop);
}
void