Fix #10987: Double-close of dropdown stopped land-info tool working as default. (#11000)

Clicking and releasing on the query toolbar icon is meant to select the land-info tool.

This did not work as during closing a window, OnFocusLost() is called, which then closes the window again. These two calls toggled the land-info tool one and off in the same action.

Resolve by not calling Window::Close in OnFocusLost() if the window is already closing.
This commit is contained in:
PeterN
2023-06-12 08:42:02 +01:00
committed by GitHub
parent 613ad80581
commit ebc451b071
5 changed files with 16 additions and 9 deletions

View File

@@ -469,7 +469,7 @@ void SetFocusedWindow(Window *w)
_focused_window = w;
/* So we can inform it that it lost focus */
if (old_focused != nullptr) old_focused->OnFocusLost();
if (old_focused != nullptr) old_focused->OnFocusLost(false);
if (_focused_window != nullptr) _focused_window->OnFocus();
}
@@ -545,7 +545,7 @@ void Window::OnFocus()
/**
* Called when window loses focus
*/
void Window::OnFocusLost()
void Window::OnFocusLost(bool closing)
{
if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
}
@@ -1132,7 +1132,7 @@ void Window::Close()
/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
if (_focused_window == this) {
this->OnFocusLost();
this->OnFocusLost(true);
_focused_window = nullptr;
}