MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Close

Method Close

src/window.cpp:1104–1136  ·  view source on GitHub ↗

* Hide the window and all its child windows, and mark them for a later deletion. */

Source from the content-addressed store, hash-verified

1102 * Hide the window and all its child windows, and mark them for a later deletion.
1103 */
1104void Window::Close([[maybe_unused]] int data)
1105{
1106 /* Don't close twice. */
1107 if (*this->z_position == nullptr) return;
1108
1109 *this->z_position = nullptr;
1110
1111 if (_thd.window_class == this->window_class &&
1112 _thd.window_number == this->window_number) {
1113 ResetObjectToPlace();
1114 }
1115
1116 /* Prevent Mouseover() from resetting mouse-over coordinates on a non-existing window */
1117 if (_mouseover_last_w == this) _mouseover_last_w = nullptr;
1118
1119 /* We can't scroll the window when it's closed. */
1120 if (_last_scroll_window == this) _last_scroll_window = nullptr;
1121
1122 /* Make sure we don't try to access non-existing query strings. */
1123 this->querystrings.clear();
1124
1125 /* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
1126 if (_focused_window == this) {
1127 this->OnFocusLost(true);
1128 _focused_window = nullptr;
1129 }
1130
1131 this->CloseChildWindows();
1132
1133 this->SetDirty();
1134
1135 Window::closed_windows.push_back(this);
1136}
1137
1138/**
1139 * Remove window and all its child windows from the window stack.

Callers 15

OnClickMethod · 0.45
OnPlaceObjectMethod · 0.45
DeleteRenameSignWindowFunction · 0.45
OnClickMethod · 0.45
OnClickMethod · 0.45
OnFocusLostMethod · 0.45
OnClickMethod · 0.45
DispatchLeftClickEventFunction · 0.45
DispatchRightClickEventFunction · 0.45
CloseChildWindowsMethod · 0.45
CloseChildWindowByIdMethod · 0.45
CloseWindowByIdFunction · 0.45

Calls 6

OnFocusLostMethod · 0.95
CloseChildWindowsMethod · 0.95
SetDirtyMethod · 0.95
ResetObjectToPlaceFunction · 0.85
push_backMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected