summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2020-01-21 20:59:01 +0100
committerCharles Pigott <charlespigott@googlemail.com>2020-01-22 19:53:27 +0000
commit341941af852d2a07c59d4c17247b294026878b30 (patch)
treeffa6cb61bc1fdb3d6a1061c79211708ace95384a /src/window.cpp
parent9d5dd893cdd6ca75d1ed7ad2aa7ca5d98feffa5f (diff)
downloadopenttd-341941af852d2a07c59d4c17247b294026878b30.tar.xz
Fix #7952: don't try to access destroyed QueryStrings
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 93777d28f..30fa4d3d1 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -389,7 +389,7 @@ QueryString *Window::GetQueryString(uint widnum)
*/
/* virtual */ Point Window::GetCaretPosition() const
{
- if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX) {
+ if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX && !this->querystrings.empty()) {
return this->GetQueryString(this->nested_focus->index)->GetCaretPosition(this, this->nested_focus->index);
}
@@ -1094,6 +1094,9 @@ Window::~Window()
/* We can't scroll the window when it's closed. */
if (_last_scroll_window == this) _last_scroll_window = nullptr;
+ /* Make sure we don't try to access non-existing query strings. */
+ this->querystrings.clear();
+
/* 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();