Loading

Paste #p7s8qpje1

  1. diff --git a/src/dropdown.cpp b/src/dropdown.cpp
  2. --- a/src/dropdown.cpp
  3. +++ b/src/dropdown.cpp
  4. @@ -135,7 +135,7 @@ void DropdownMenuWindow::OnClick(WidgetN
  5.         int send = this->parent_btn << 16 | index;
  6.         NotifyChange(this->parent_type, this->parent_num, CHG_DROPDOWN_RESULT, send);
  7.  
  8. -       _window_manager.DeleteWindow(this);
  9. +       delete this;
  10.  }
  11.  
  12.  /**
  13. @@ -148,7 +148,7 @@ void DropdownMenuWindow::OnClick(WidgetN
  14.  void GuiWindow::ShowDropdownMenu(WidgetNumber widnum, const DropdownList &items, int selected_index, ColourRange colour)
  15.  {
  16.         Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE);
  17. -       if (w != nullptr) _window_manager.DeleteWindow(w);
  18. +       if (w != nullptr) delete w;
  19.  
  20.         DataWidget *wid = this->GetWidget<DataWidget>(widnum);
  21.         assert(wid->wtype == WT_DROPDOWN_BUTTON);
  22. @@ -253,7 +253,7 @@ void RecolourDropdownWindow::OnClick(Wid
  23.                         _video.MarkDisplayDirty();
  24.                 }
  25.  
  26. -               _window_manager.DeleteWindow(this);
  27. +               delete this;
  28.         }
  29.  }
  30.  
  31. @@ -273,7 +273,7 @@ void RecolourDropdownWindow::DrawWidget(
  32.  void GuiWindow::ShowRecolourDropdown(WidgetNumber widnum, RecolourEntry *entry, ColourRange colour)
  33.  {
  34.         Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE);
  35. -       if (w != nullptr) _window_manager.DeleteWindow(w);
  36. +       if (w != nullptr) delete w;
  37.  
  38.         DataWidget *wid = this->GetWidget<DataWidget>(widnum);
  39.         assert(wid->wtype == WT_DROPDOWN_BUTTON);
  40. diff --git a/src/person.cpp b/src/person.cpp
  41. --- a/src/person.cpp
  42. +++ b/src/person.cpp
  43. @@ -1030,9 +1030,7 @@ void Guest::DeActivate(AnimateResult ar)
  44.         if (this->IsActive()) {
  45.                 /* Close possible Guest Info window */
  46.                 Window *wi = GetWindowByType(WC_GUEST_INFO, this->id);
  47. -               if (wi != nullptr) {
  48. -                       _window_manager.DeleteWindow(wi);
  49. -               }
  50. +               if (wi != nullptr) delete wi;
  51.  
  52.                 /// \todo Evaluate Guest::total_happiness against scenario requirements for evaluating the park value.
  53.         }
  54. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  55. --- a/src/toolbar_gui.cpp
  56. +++ b/src/toolbar_gui.cpp
  57. @@ -447,14 +447,14 @@ QuitProgramWindow::QuitProgramWindow() :
  58.  void QuitProgramWindow::OnClick(WidgetNumber number, const Point16 &pos)
  59.  {
  60.         if (number == QP_YES) QuitProgram();
  61. -       _window_manager.DeleteWindow(this);
  62. +       delete this;
  63.  }
  64.  
  65.  /** Ask the user whether the program should be stopped. */
  66.  void ShowQuitProgram()
  67.  {
  68.         Window *w = GetWindowByType(WC_QUIT, ALL_WINDOWS_OF_TYPE);
  69. -       if (w != nullptr) _window_manager.DeleteWindow(w);
  70. +       if (w != nullptr) delete w;
  71.  
  72.         new QuitProgramWindow();
  73.  }
  74. diff --git a/src/window.cpp b/src/window.cpp
  75. --- a/src/window.cpp
  76. +++ b/src/window.cpp
  77. @@ -64,13 +64,11 @@ Window::Window(WindowTypes wtype, Window
  78.         _window_manager.AddToStack(this); // Add to window stack.
  79.  }
  80.  
  81. -/**
  82. - * Destructor.
  83. - * Do not call directly, use #WindowManager::DeleteWindow instead.
  84. - */
  85. +/** Destructor. */
  86.  Window::~Window()
  87.  {
  88. -       assert(!_window_manager.HasWindow(this));
  89. +       _window_manager.RemoveFromStack(this);
  90. +       this->MarkDirty();
  91.  }
  92.  
  93.  /**
  94. @@ -653,9 +651,7 @@ WindowManager::~WindowManager()
  95.  /** Close all windows at the display. */
  96.  void WindowManager::CloseAllWindows()
  97.  {
  98. -       while (this->top != nullptr) {
  99. -               this->DeleteWindow(this->top);
  100. -       }
  101. +       while (this->top != nullptr) delete this->top;
  102.  }
  103.  
  104.  /** Reinitialize all windows in the display. */
  105. @@ -763,17 +759,6 @@ void WindowManager::RemoveFromStack(Wind
  106.  }
  107.  
  108.  /**
  109. - * Delete a window.
  110. - * @param w Window to remove.
  111. - */
  112. -void WindowManager::DeleteWindow(Window *w)
  113. -{
  114. -       this->RemoveFromStack(w);
  115. -       w->MarkDirty();
  116. -       delete w;
  117. -}
  118. -
  119. -/**
  120.   * Raise a window.
  121.   * @param w Window to raise.
  122.   */
  123. @@ -929,7 +914,7 @@ void WindowManager::MouseButtonEvent(Mou
  124.         /* Close dropdown window if click is not inside it */
  125.         Window *w = GetWindowByType(WC_DROPDOWN, ALL_WINDOWS_OF_TYPE);
  126.         if (pressed && w != nullptr && !w->rect.IsPointInside(this->mouse_pos)) {
  127. -               this->DeleteWindow(w);
  128. +               delete w;
  129.                 return; // Don't handle click any further.
  130.         }
  131.  
  132. @@ -948,7 +933,7 @@ void WindowManager::MouseButtonEvent(Mou
  133.                                                 break;
  134.  
  135.                                         case WMME_CLOSE_WINDOW:
  136. -                                               this->DeleteWindow(this->current_window);
  137. +                                               delete this->current_window;
  138.                                                 break;
  139.  
  140.                                         default:
  141. diff --git a/src/window.h b/src/window.h
  142. --- a/src/window.h
  143. +++ b/src/window.h
  144. @@ -326,7 +326,6 @@ public:
  145.         bool HasWindow(Window *w);
  146.         void AddToStack(Window *w);
  147.         void RemoveFromStack(Window *w);
  148. -       void DeleteWindow(Window *w);
  149.         void RaiseWindow(Window *w);
  150.  
  151.         void CloseAllWindows();

Comments