From 5107fb662580da57f82951048f36202536d6d375 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 24 Jul 2023 12:39:06 +1000 Subject: [PATCH] Cleanup: quiet ASAN warning initializing eWM_CapabilitiesFlag to -1 ASAN warns about this since moving wm_window.c to C++, add an initialized flag instead of using an invalid value to represent an uninitialized state. --- source/blender/windowmanager/WM_api.h | 2 ++ source/blender/windowmanager/intern/wm_window.cc | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 541906cb61c..d9fc745132c 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -173,6 +173,8 @@ typedef enum eWM_CapabilitiesFlag { WM_CAPABILITY_GPU_FRONT_BUFFER_READ = (1 << 3), /** Ability to copy/paste system clipboard images. */ WM_CAPABILITY_CLIPBOARD_IMAGES = (1 << 4), + /** The initial value, indicates the value needs to be set by inspecting GHOST. */ + WM_CAPABILITY_INITIALIZED = (1 << 31), } eWM_CapabilitiesFlag; ENUM_OPERATORS(eWM_CapabilitiesFlag, WM_CAPABILITY_CLIPBOARD_IMAGES) diff --git a/source/blender/windowmanager/intern/wm_window.cc b/source/blender/windowmanager/intern/wm_window.cc index 67236105551..02d31f67fbe 100644 --- a/source/blender/windowmanager/intern/wm_window.cc +++ b/source/blender/windowmanager/intern/wm_window.cc @@ -1866,11 +1866,11 @@ void wm_test_opengl_deprecation_warning(bContext *C) eWM_CapabilitiesFlag WM_capabilities_flag() { - static eWM_CapabilitiesFlag flag = eWM_CapabilitiesFlag(-1); - if (flag != -1) { + static eWM_CapabilitiesFlag flag = eWM_CapabilitiesFlag(0); + if (flag != 0) { return flag; } - flag = eWM_CapabilitiesFlag(0); + flag |= WM_CAPABILITY_INITIALIZED; const GHOST_TCapabilityFlag ghost_flag = GHOST_GetCapabilities(); if (ghost_flag & GHOST_kCapabilityCursorWarp) {