mirror of https://github.com/OpenTTD/OpenTTD.git
Fix #7952: don't try to access destroyed QueryStrings
This commit is contained in:
parent
9d5dd893cd
commit
341941af85
|
@ -389,7 +389,7 @@ QueryString *Window::GetQueryString(uint widnum)
|
||||||
*/
|
*/
|
||||||
/* virtual */ Point Window::GetCaretPosition() const
|
/* 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);
|
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. */
|
/* We can't scroll the window when it's closed. */
|
||||||
if (_last_scroll_window == this) _last_scroll_window = nullptr;
|
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. */
|
/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
|
||||||
if (_focused_window == this) {
|
if (_focused_window == this) {
|
||||||
this->OnFocusLost();
|
this->OnFocusLost();
|
||||||
|
|
Loading…
Reference in New Issue