From 18e3c81cf56c102c21f5c20989759107131dfe2a Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Thu, 7 Jan 2021 17:53:39 +0000 Subject: [PATCH] Bug 1684896 - For the static NSDictionary MacSelectorMap objects, use function-local statics rather than globals. r=morgan This means that the NSDictionaries will be constructed the first time the wrapper function is called, and not at C++ static initializer time. This avoids false positive warnings when running with the environment variables `OBJC_DEBUG_MISSING_POOLS=YES LIBDISPATCH_DEBUG_MISSING_POOLS=NO`. Differential Revision: https://phabricator.services.mozilla.com/D100976 --- accessible/mac/SelectorMapGen.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/accessible/mac/SelectorMapGen.py b/accessible/mac/SelectorMapGen.py index 5864120fbc41..c3504a175154 100755 --- a/accessible/mac/SelectorMapGen.py +++ b/accessible/mac/SelectorMapGen.py @@ -11,14 +11,14 @@ import re def write_map(fd, name, text): matches = re.findall(r"^//\s(AX\w+)\n-\s?\(.*?\)([\w:]+)", text, re.MULTILINE) - entries = [' @"%s" : @"%s"' % (a, s) for [a, s] in matches] - - fd.write("static NSDictionary* g%s = @{\n" % name) - fd.write(",\n".join(entries)) - fd.write("\n};\n\n") + entries = [' @"%s" : @"%s"' % (a, s) for [a, s] in matches] fd.write("NSDictionary* %s() {\n" % name) - fd.write(" return g%s;\n" % name) + fd.write(" // Create an autoreleased NSDictionary object once, and leak it.\n") + fd.write(" static NSDictionary* s%s = [@{\n" % name) + fd.write(",\n".join(entries)) + fd.write("\n } retain];\n\n") + fd.write(" return s%s;\n" % name) fd.write("}\n\n")