Skip to content

Commit 94ef825

Browse files
author
Dominik Witczak
committed
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.
1 parent 021b15b commit 94ef825

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

src/misc/window_win3264.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,10 @@ Anvil::WindowUniquePtr Anvil::WindowWin3264::create(const std::string&
8888
/** Please see header for specification */
8989
Anvil::WindowUniquePtr Anvil::WindowWin3264::create(HWND in_window_handle)
9090
{
91-
WindowUniquePtr result_ptr(nullptr,
92-
std::default_delete<Window>() );
93-
RECT window_rect;
94-
uint32_t window_size[2] = {0};
95-
std::vector<char> window_title;
96-
uint32_t window_title_length = 0;
91+
WindowUniquePtr result_ptr(nullptr,
92+
std::default_delete<Window>() );
93+
RECT window_rect;
94+
uint32_t window_size[2] = {0};
9795

9896
/* The window has already been spawned by the user. Gather all the info we need in order to instantiate
9997
* the wrapper instance.
@@ -116,21 +114,10 @@ Anvil::WindowUniquePtr Anvil::WindowWin3264::create(HWND in_window_handle)
116114
window_size[0] = static_cast<uint32_t>(window_rect.right - window_rect.left);
117115
window_size[1] = static_cast<uint32_t>(window_rect.bottom - window_rect.top);
118116

119-
window_title_length = static_cast<uint32_t>(::GetWindowTextLength(in_window_handle) );
120-
121-
if (window_title_length != 0)
122-
{
123-
window_title.resize(window_title_length);
124-
125-
::GetWindowText(in_window_handle,
126-
static_cast<LPSTR>(&window_title.at(0) ),
127-
static_cast<int> (window_title_length) );
128-
}
129-
130117
/* Go ahead and create the window wrapper instance */
131118
result_ptr.reset(
132119
new Anvil::WindowWin3264(in_window_handle,
133-
std::string(&window_title.at(0) ),
120+
"HWND wrapper window instance",
134121
window_size[0],
135122
window_size[1],
136123
nullptr) /* present_callback_func_ptr */

0 commit comments

Comments
 (0)