From 94ef8257cc0dff37a4f4e983ced8870f58fe8c0d Mon Sep 17 00:00:00 2001 From: Dominik Witczak Date: Sat, 27 Oct 2018 14:14:29 +0200 Subject: [PATCH] Fix a lock-up which could occur if: 1) Window thread T1 became temporarily unresponsive, waiting for T2 to finish 2) Thread T2 tried to create an Anvil window instance for window owned by T1. The lock-up occurred because GetWindowTextLength() actually maps to a window message which cannot be handled because T1 is waiting on T2. There's no real solution other than just getting rid of the circular dependency, meaning we need Anvil to stop trying to retrieve window name at Anvil::Window creation time. --- src/misc/window_win3264.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/misc/window_win3264.cpp b/src/misc/window_win3264.cpp index 77d2977c..24ae41e4 100644 --- a/src/misc/window_win3264.cpp +++ b/src/misc/window_win3264.cpp @@ -88,12 +88,10 @@ Anvil::WindowUniquePtr Anvil::WindowWin3264::create(const std::string& /** Please see header for specification */ Anvil::WindowUniquePtr Anvil::WindowWin3264::create(HWND in_window_handle) { - WindowUniquePtr result_ptr(nullptr, - std::default_delete() ); - RECT window_rect; - uint32_t window_size[2] = {0}; - std::vector window_title; - uint32_t window_title_length = 0; + WindowUniquePtr result_ptr(nullptr, + std::default_delete() ); + RECT window_rect; + uint32_t window_size[2] = {0}; /* The window has already been spawned by the user. Gather all the info we need in order to instantiate * the wrapper instance. @@ -116,21 +114,10 @@ Anvil::WindowUniquePtr Anvil::WindowWin3264::create(HWND in_window_handle) window_size[0] = static_cast(window_rect.right - window_rect.left); window_size[1] = static_cast(window_rect.bottom - window_rect.top); - window_title_length = static_cast(::GetWindowTextLength(in_window_handle) ); - - if (window_title_length != 0) - { - window_title.resize(window_title_length); - - ::GetWindowText(in_window_handle, - static_cast(&window_title.at(0) ), - static_cast (window_title_length) ); - } - /* Go ahead and create the window wrapper instance */ result_ptr.reset( new Anvil::WindowWin3264(in_window_handle, - std::string(&window_title.at(0) ), + "HWND wrapper window instance", window_size[0], window_size[1], nullptr) /* present_callback_func_ptr */