diff --git a/src/dropdown.cpp b/src/dropdown.cpp --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -135,7 +135,7 @@ void DropdownMenuWindow::OnClick(WidgetN int send = this->parent_btn << 16 | index; NotifyChange(this->parent_type, this->parent_num, CHG_DROPDOWN_RESULT, send); - _window_manager.DeleteWindow(this); + delete this; } /** @@ -148,7 +148,7 @@ void DropdownMenuWindow::OnClick(WidgetN void GuiWindow::ShowDropdownMenu(WidgetNumber widnum, const DropdownList &items, int selected_index, ColourRange colour) { Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE); - if (w != nullptr) _window_manager.DeleteWindow(w); + if (w != nullptr) delete w; DataWidget *wid = this->GetWidget(widnum); assert(wid->wtype == WT_DROPDOWN_BUTTON); @@ -253,7 +253,7 @@ void RecolourDropdownWindow::OnClick(Wid _video.MarkDisplayDirty(); } - _window_manager.DeleteWindow(this); + delete this; } } @@ -273,7 +273,7 @@ void RecolourDropdownWindow::DrawWidget( void GuiWindow::ShowRecolourDropdown(WidgetNumber widnum, RecolourEntry *entry, ColourRange colour) { Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE); - if (w != nullptr) _window_manager.DeleteWindow(w); + if (w != nullptr) delete w; DataWidget *wid = this->GetWidget(widnum); assert(wid->wtype == WT_DROPDOWN_BUTTON); diff --git a/src/person.cpp b/src/person.cpp --- a/src/person.cpp +++ b/src/person.cpp @@ -1030,9 +1030,7 @@ void Guest::DeActivate(AnimateResult ar) if (this->IsActive()) { /* Close possible Guest Info window */ Window *wi = GetWindowByType(WC_GUEST_INFO, this->id); - if (wi != nullptr) { - _window_manager.DeleteWindow(wi); - } + if (wi != nullptr) delete wi; /// \todo Evaluate Guest::total_happiness against scenario requirements for evaluating the park value. } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -447,14 +447,14 @@ QuitProgramWindow::QuitProgramWindow() : void QuitProgramWindow::OnClick(WidgetNumber number, const Point16 &pos) { if (number == QP_YES) QuitProgram(); - _window_manager.DeleteWindow(this); + delete this; } /** Ask the user whether the program should be stopped. */ void ShowQuitProgram() { Window *w = GetWindowByType(WC_QUIT, ALL_WINDOWS_OF_TYPE); - if (w != nullptr) _window_manager.DeleteWindow(w); + if (w != nullptr) delete w; new QuitProgramWindow(); } diff --git a/src/window.cpp b/src/window.cpp --- a/src/window.cpp +++ b/src/window.cpp @@ -64,13 +64,11 @@ Window::Window(WindowTypes wtype, Window _window_manager.AddToStack(this); // Add to window stack. } -/** - * Destructor. - * Do not call directly, use #WindowManager::DeleteWindow instead. - */ +/** Destructor. */ Window::~Window() { - assert(!_window_manager.HasWindow(this)); + _window_manager.RemoveFromStack(this); + this->MarkDirty(); } /** @@ -653,9 +651,7 @@ WindowManager::~WindowManager() /** Close all windows at the display. */ void WindowManager::CloseAllWindows() { - while (this->top != nullptr) { - this->DeleteWindow(this->top); - } + while (this->top != nullptr) delete this->top; } /** Reinitialize all windows in the display. */ @@ -763,17 +759,6 @@ void WindowManager::RemoveFromStack(Wind } /** - * Delete a window. - * @param w Window to remove. - */ -void WindowManager::DeleteWindow(Window *w) -{ - this->RemoveFromStack(w); - w->MarkDirty(); - delete w; -} - -/** * Raise a window. * @param w Window to raise. */ @@ -929,7 +914,7 @@ void WindowManager::MouseButtonEvent(Mou /* Close dropdown window if click is not inside it */ Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE); if (pressed && w != nullptr && !w->rect.IsPointInside(this->mouse_pos)) { - this->DeleteWindow(w); + delete w; return; // Don't handle click any further. } @@ -948,7 +933,7 @@ void WindowManager::MouseButtonEvent(Mou break; case WMME_CLOSE_WINDOW: - this->DeleteWindow(this->current_window); + delete this->current_window; break; default: diff --git a/src/window.h b/src/window.h --- a/src/window.h +++ b/src/window.h @@ -326,7 +326,6 @@ public: bool HasWindow(Window *w); void AddToStack(Window *w); void RemoveFromStack(Window *w); - void DeleteWindow(Window *w); void RaiseWindow(Window *w); void CloseAllWindows();