Skip to content

Commit

Permalink
Updating webui_wait()
Browse files Browse the repository at this point in the history
- Now `webui_wait()` should exit faster if all windows failed to start
  • Loading branch information
hassandraga committed Sep 22, 2023
1 parent 58f294e commit ffccf74
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ bool webui_show(size_t window, const char* content) {
printf("[User] webui_show([%zu])...\n", window);
#endif

_webui_core.ui = true;

// Dereference
_webui_init();
if(_webui_core.exit_now || _webui_core.wins[window] == NULL) return false;
Expand All @@ -704,8 +702,6 @@ bool webui_show_browser(size_t window, const char* content, size_t browser) {
printf("[User] webui_show_browser([%zu], [%zu])...\n", window, browser);
#endif

_webui_core.ui = true;

// Dereference
_webui_init();
if(_webui_core.exit_now || _webui_core.wins[window] == NULL) return false;
Expand Down Expand Up @@ -1363,8 +1359,14 @@ void webui_wait(void) {
// Check if there is atleast one window (UI)
// is running. Otherwise the mutex condition
// signal will never come
if(!_webui_core.ui)
if(!_webui_core.ui) {

printf("[Loop] webui_wait() -> No window is found. Stop.\n");

// Final cleaning
_webui_clean();
return;
}

#ifdef WEBUI_LOG
printf("[Loop] webui_wait() -> Timeout in %zu seconds\n", _webui_core.startup_timeout);
Expand Down Expand Up @@ -2722,7 +2724,7 @@ static bool _webui_browser_create_profile_folder(_webui_window_t* win, size_t br

char buf[2048] = {0};

sprintf(buf, "\"%s\" -CreateProfile \"WebUI %s\"", win->browser_path, firefox_profile_path);
sprintf(buf, "%s -CreateProfile \"WebUI %s\"", win->browser_path, firefox_profile_path);
_webui_cmd_sync(win, buf, false);

// Creating the browser profile
Expand Down Expand Up @@ -4285,6 +4287,8 @@ static bool _webui_show_window(_webui_window_t* win, const char* content, bool i
_webui_free_port(win->ws_port);
return false;
}

_webui_core.ui = true;

// New server thread
#ifdef _WIN32
Expand Down

0 comments on commit ffccf74

Please sign in to comment.