commit 33d549538bdba7acf91c7a01626335d6d4afe727
parent 61434a59aa6349ceef359a2d8f0b3fce938a0c91
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Thu, 18 Jun 2015 10:42:14 -0400
UI: Capture Messages During Initialization
Previously during the construction of the GUI a number of messages
would receive responses, however these would not be routed to widgets
as the gui callback was not set until after initialization.
These messages are now captured in a temporary vector and played back
to the UI after setting the callback.
This should fix some startup weirdness which has been visible
in the past.
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
@@ -429,11 +429,29 @@ int main(int argc, char *argv[])
gui = NULL;
+
+ //Capture Startup Responses
+ typedef std::vector<const char *> wait_t;
+ wait_t msg_waitlist;
+ middleware->setUiCallback([](void*v,const char*msg) {
+ wait_t &wait = *(wait_t*)v;
+ size_t len = rtosc_message_length(msg, -1);
+ char *copy = new char[len];
+ memcpy(copy, msg, len);
+ wait.push_back(copy);
+ }, &msg_waitlist);
+
if(!noui)
gui = GUI::createUi(middleware->spawnUiApi(), &Pexitprogram);
middleware->setUiCallback(GUI::raiseUi, gui);
middleware->setIdleCallback([](void*){GUI::tickUi(gui);}, NULL);
+ //Replay Startup Responses
+ for(auto msg:msg_waitlist) {
+ GUI::raiseUi(gui, msg);
+ delete [] msg;
+ }
+
if(!noui)
{
GUI::raiseUi(gui, "/show", "i", config.cfg.UserInterfaceMode);