From cc617dc5d117cb2c979de6fb76c64620ab7cf04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 16 Mar 2018 08:40:33 +0100 Subject: [PATCH] SCons: properly close files when reading controller mappings Fixup to #17296. --- main/SCsub | 8 ++++---- main/default_controller_mappings.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main/SCsub b/main/SCsub index ab4016190df..dd16437d5c4 100644 --- a/main/SCsub +++ b/main/SCsub @@ -74,10 +74,9 @@ def make_default_controller_mappings(target, source, env): platform_mappings = OrderedDict() for src in source: src_path = src.srcnode().abspath - f = open(src_path, "rb") - - # read mapping file and skip header - mapping_file_lines = f.readlines()[2:] + with open(src_path, "rb") as f: + # read mapping file and skip header + mapping_file_lines = f.readlines()[2:] current_platform = None for line in mapping_file_lines: @@ -123,6 +122,7 @@ def make_default_controller_mappings(target, source, env): g.write("#endif\n") g.write("};\n") + g.close() env.main_sources = [] env.add_source_files(env.main_sources, "*.cpp") diff --git a/main/default_controller_mappings.h b/main/default_controller_mappings.h index 980f7578eb6..6319b875eb2 100644 --- a/main/default_controller_mappings.h +++ b/main/default_controller_mappings.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* input_default.h */ +/* default_controller_mappings.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -36,4 +36,4 @@ public: static const char *mappings[]; }; -#endif // DEFAULT_CONTROLLER_MAPPINGS_H \ No newline at end of file +#endif // DEFAULT_CONTROLLER_MAPPINGS_H