Add DestroyAllWindows helper that uses vector copy
authorKevin Sawicki <kevinsawicki@gmail.com>
Thu, 6 Apr 2017 21:25:22 +0000 (14:25 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 11 Apr 2017 16:09:17 +0000 (09:09 -0700)
atom/browser/browser.cc
atom/browser/window_list.cc
atom/browser/window_list.h

index b18ab7b70fd751afa5ca6b45e2023ad790a66b58..1df1f316c1b880721ae80a9855e499a3abb625d6 100644 (file)
@@ -71,8 +71,7 @@ void Browser::Exit(mate::Arguments* args) {
     } else {
       // Unlike Quit(), we do not ask to close window, but destroy the window
       // without asking.
-      for (NativeWindow* window : *window_list)
-        window->CloseContents(nullptr);  // e.g. Destroy()
+      atom::WindowList::DestroyAllWindows();
     }
   }
 }
index d627f6d1206b01dca86fa7e390e615fdbc23173d..bcf4a9f1e2c006a6231d7ef1620c22c07699e6f2 100644 (file)
@@ -76,6 +76,13 @@ void WindowList::CloseAllWindows() {
       window->Close();
 }
 
+// static
+void WindowList::DestroyAllWindows() {
+  WindowVector windows = GetInstance()->windows_;
+  for (const auto& window : windows)
+    window->CloseContents(nullptr);  // e.g. Destroy()
+}
+
 WindowList::WindowList() {
 }
 
index d9b307352e901c5846aabc8b66ee7ee1067e9ae8..557a7969e59a1ba8c100655868636e8c086a21cf 100644 (file)
@@ -51,6 +51,9 @@ class WindowList {
   // Closes all windows.
   static void CloseAllWindows();
 
+  // Destroy all windows.
+  static void DestroyAllWindows();
+
  private:
   WindowList();
   ~WindowList();