Moving threads to XHostThread and making shutdown not crash.

This commit is contained in:
Ben Vanik
2015-05-19 22:20:49 -07:00
parent 7a82ad839a
commit f88bf33b4f
22 changed files with 175 additions and 138 deletions

View File

@@ -17,6 +17,7 @@ Win32Control::Win32Control(uint32_t flags) : Control(flags), hwnd_(nullptr) {}
Win32Control::~Win32Control() {
if (hwnd_) {
SetWindowLongPtr(hwnd_, GWLP_USERDATA, 0);
CloseWindow(hwnd_);
hwnd_ = nullptr;
}

View File

@@ -29,7 +29,7 @@ class PostedFn {
Win32Loop::Win32Loop() : thread_id_(0) {
xe::threading::Fence init_fence;
thread_ = std::thread([&]() {
thread_ = std::thread([&init_fence, this]() {
xe::threading::set_name("Win32 Loop");
thread_id_ = GetCurrentThreadId();
@@ -46,7 +46,10 @@ Win32Loop::Win32Loop() : thread_id_(0) {
init_fence.Wait();
}
Win32Loop::~Win32Loop() = default;
Win32Loop::~Win32Loop() {
Quit();
thread_.join();
}
void Win32Loop::ThreadMain() {
MSG msg;