From 64751a0be491be2f046fb7338a02f1ccf7db4f90 Mon Sep 17 00:00:00 2001 From: James Darpinian Date: Wed, 7 Aug 2019 15:08:51 -0700 Subject: [PATCH] Reenable extra_warnings config for angle_utils Originally disabled in https://crrev.com/c/1738438. Bug: angleproject:1459 Change-Id: I95172dc95a5d3e9d838c542ee6bcfb2338ffc9a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1743078 Commit-Queue: Jamie Madill Reviewed-by: Jamie Madill --- BUILD.gn | 1 - util/osx/OSXWindow.mm | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index da9811fd33a..435ac3eb801 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1077,7 +1077,6 @@ foreach(is_shared_library, } configs += [ ":debug_annotations_config" ] - configs -= [ "${angle_root}:extra_warnings" ] public_configs += [ ":angle_util_config" ] diff --git a/util/osx/OSXWindow.mm b/util/osx/OSXWindow.mm index abd6007b7b5..5b6dfe056ca 100644 --- a/util/osx/OSXWindow.mm +++ b/util/osx/OSXWindow.mm @@ -12,6 +12,7 @@ // Include Carbon to use the keycode names in Carbon's Event.h #include +#include "anglebase/no_destructor.h" #include "common/debug.h" // On OSX 10.12 a number of AppKit interfaces have been renamed for consistency, and the previous @@ -23,7 +24,11 @@ // Some events such as "ShouldTerminate" are sent to the whole application so we keep a list of // all the windows in order to forward the event to each of them. However this and calling pushEvent // in ApplicationDelegate is inherently unsafe in a multithreaded environment. -static std::set gAllWindows; +static std::set &AllWindows() +{ + static angle::base::NoDestructor> allWindows; + return *allWindows; +} @interface Application : NSApplication @end @@ -33,7 +38,7 @@ - (void)sendEvent:(NSEvent *)nsEvent { if ([nsEvent type] == NSApplicationDefined) { - for (auto window : gAllWindows) + for (auto window : AllWindows()) { if ([window->getNSWindow() windowNumber] == [nsEvent windowNumber]) { @@ -56,7 +61,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende { Event event; event.Type = Event::EVENT_CLOSED; - for (auto window : gAllWindows) + for (auto window : AllWindows()) { window->pushEvent(event); } @@ -662,13 +667,13 @@ - (void)flagsChanged:(NSEvent *)nsEvent mWidth = width; mHeight = height; - gAllWindows.insert(this); + AllWindows().insert(this); return true; } void OSXWindow::destroy() { - gAllWindows.erase(this); + AllWindows().erase(this); [mView release]; mView = nil;