Use context manager for handling G.progress_lock

Manually calling `G.progress_lock.release()` is error-prone as it's not
called when an exception is raised while the lock is acquired.
This commit is contained in:
2018-08-14 13:43:29 +02:00
parent d252f75acf
commit c915a486cb
2 changed files with 74 additions and 86 deletions

View File

@@ -77,12 +77,11 @@ def draw_image(filepath, x, y, w, h):
# Draw.
def benchmark_draw_post_pixel(arg1, arg2):
G.progress_lock.acquire()
progress_status = G.progress_status
result_platform = G.result_platform
result_stats = G.result_stats
result_dict = G.result_dict
G.progress_lock.release()
with G.progress_lock:
progress_status = G.progress_status
result_platform = G.result_platform
result_stats = G.result_stats
result_dict = G.result_dict
ui_scale = bpy.context.user_preferences.system.ui_scale
blf.color(font_id, 1.0, 1.0, 1.0, 1.0)