Skip to content

Commit

Permalink
WinUpdater: Wait in UI::Init until window is done creating to avoid l…
Browse files Browse the repository at this point in the history
…osing UI::SetVisible signals
  • Loading branch information
CookiePLMonster committed Aug 6, 2019
1 parent f70efbb commit 8e79705
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/Core/WinUpdater/WinUI.cpp
Expand Up @@ -12,6 +12,8 @@
#include <ShObjIdl.h> #include <ShObjIdl.h>
#include <shellapi.h> #include <shellapi.h>


#include "Common/Event.h"
#include "Common/ScopeGuard.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"


namespace namespace
Expand All @@ -23,6 +25,7 @@ HWND current_progressbar_handle = nullptr;
ITaskbarList3* taskbar_list = nullptr; ITaskbarList3* taskbar_list = nullptr;


std::thread ui_thread; std::thread ui_thread;
Common::Event window_created_event;


int GetWindowHeight(HWND hwnd) int GetWindowHeight(HWND hwnd)
{ {
Expand Down Expand Up @@ -54,6 +57,9 @@ bool InitWindow()
{ {
InitCommonControls(); InitCommonControls();


// Notify main thread we're done creating the window when we return
Common::ScopeGuard ui_guard{[] { window_created_event.Set(); }};

WNDCLASS wndcl = {}; WNDCLASS wndcl = {};
wndcl.lpfnWndProc = WindowProc; wndcl.lpfnWndProc = WindowProc;
wndcl.hbrBackground = GetSysColorBrush(COLOR_MENU); wndcl.hbrBackground = GetSysColorBrush(COLOR_MENU);
Expand Down Expand Up @@ -226,6 +232,9 @@ void MessageLoop()
void Init() void Init()
{ {
ui_thread = std::thread(MessageLoop); ui_thread = std::thread(MessageLoop);

// Wait for UI thread to finish creating the window (or at least attempting to)
window_created_event.Wait();
} }


void Stop() void Stop()
Expand Down

0 comments on commit 8e79705

Please sign in to comment.