From 4a1e70c34812be2d7f018e7fa5aa2fee0ac59ecb Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 13:47:58 -0700 Subject: [PATCH 01/63] build(msvc): RED: pin /W4 and no /WX in link options (#2626) --- ci/test_msvc_warning_level.py | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 ci/test_msvc_warning_level.py diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py new file mode 100644 index 0000000000..9ce9880b24 --- /dev/null +++ b/ci/test_msvc_warning_level.py @@ -0,0 +1,54 @@ +#!/usr/bin/env -S uv run --script +"""The MSVC build compiles at /W4 and does not hand /WX to the linker (#2626). + + uv run python -m unittest ci/test_msvc_warning_level.py + +`/WX` is not a compile flag this file sets: `CMAKE_COMPILE_WARNING_AS_ERROR` +in `cmake/common/compiler_common.cmake` makes CMake pass it to `cl.exe` +(#516). The `add_link_options(/WX)` block was dead — `link.exe` ignores +`/WX` — so it is gone and only the compile-time setting carries the intent. +The warning level itself is `/W4`, the strictest level `cl.exe` has. +""" + +from __future__ import annotations + +import re +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +WINDOWS = ROOT / "cmake" / "windows" / "compilerconfig.cmake" +COMMON = ROOT / "cmake" / "common" / "compiler_common.cmake" + + +def call_tokens(text: str, name: str) -> list[str]: + """Every whitespace-separated argument of each `name(...)` call.""" + calls = re.findall(rf"{name}\(([^)]*)\)", text, re.S) + if not calls: + raise AssertionError(f"no {name}( call") + return [token for body in calls for token in body.split()] + + +class MsvcWarningLevelTest(unittest.TestCase): + def setUp(self) -> None: + self.text = WINDOWS.read_text(encoding="utf-8") + + def test_compile_options_request_w4(self) -> None: + options = call_tokens(self.text, "add_compile_options") + self.assertIn("/W4", options) + self.assertNotIn("/W3", options) + + def test_no_w3_anywhere(self) -> None: + self.assertIsNone(re.search(r"(? None: + self.assertNotIn("/WX", call_tokens(self.text, "add_link_options")) + + def test_wx_comes_from_the_compile_time_setting(self) -> None: + common = COMMON.read_text(encoding="utf-8") + self.assertIn("set(CMAKE_COMPILE_WARNING_AS_ERROR ON)", common) + self.assertNotIn("/WX", call_tokens(self.text, "add_compile_options")) + + +if __name__ == "__main__": + unittest.main() From 59752e5b1981909abba964d8f28537f57f9980f6 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 13:48:05 -0700 Subject: [PATCH 02/63] build(msvc): compile at /W4 and drop the dead /WX link option (#2626) --- cmake/windows/compilerconfig.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmake/windows/compilerconfig.cmake b/cmake/windows/compilerconfig.cmake index b2620ce19a..e060111765 100644 --- a/cmake/windows/compilerconfig.cmake +++ b/cmake/windows/compilerconfig.cmake @@ -65,7 +65,7 @@ if(CMAKE_CXX_STANDARD GREATER_EQUAL 20) endif() add_compile_options( - /W3 + /W4 /utf-8 /Brepro /permissive- @@ -97,7 +97,3 @@ add_link_options( /DEBUG /Brepro ) - -if(CMAKE_COMPILE_WARNING_AS_ERROR) - add_link_options(/WX) -endif() From 993a2e876a5f6edd03227659dc62d083500485a0 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 13:59:10 -0700 Subject: [PATCH 03/63] build(msvc): exempt the vendored deps from the /W4-only warnings (#2626) --- deps/libcaption/CMakeLists.txt | 3 +++ deps/w32-pthreads/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/deps/libcaption/CMakeLists.txt b/deps/libcaption/CMakeLists.txt index 9b462979d9..cba20daaff 100644 --- a/deps/libcaption/CMakeLists.txt +++ b/deps/libcaption/CMakeLists.txt @@ -39,6 +39,9 @@ target_compile_options( $<$:-Wno-cast-qual> $<$:-Wno-comma> $<$:-Wno-pedantic> + # MSVC /W4 (#2626): vendored upstream C stays vendored, with its own + # suppressions instead of edits (the #516 vendored-code exemption). + $<$:/wd4244> ) set_target_properties(caption PROPERTIES FOLDER deps POSITION_INDEPENDENT_CODE TRUE) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt index 257e75249d..005ec1da70 100644 --- a/deps/w32-pthreads/CMakeLists.txt +++ b/deps/w32-pthreads/CMakeLists.txt @@ -10,6 +10,19 @@ target_sources( target_compile_definitions(w32-pthreads PRIVATE __CLEANUP_C PTW32_BUILD) +# MSVC /W4 (#2626): vendored pthreads-win32 keeps its own suppressions rather +# than source edits (the #516 vendored-code exemption): C4324 alignment +# padding, C4057 indirection of a volatile LONG64/size_t pair in the MCS lock, +# C4310 a truncating constant cast, C4456 a shadowed local. +target_compile_options( + w32-pthreads + PRIVATE + $<$:/wd4057> + $<$:/wd4310> + $<$:/wd4324> + $<$:/wd4456> +) + target_include_directories(w32-pthreads PUBLIC "$") configure_file(cmake/windows/obs-module.rc.in w32-pthreads.rc) From 9d28ea43900d76cd0114b12ecbed543c900acc83 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 14:26:56 -0700 Subject: [PATCH 04/63] build(msvc): extend the vendored /W4 exemptions to C4701-C4703 (#2626) --- deps/libcaption/CMakeLists.txt | 3 +++ deps/w32-pthreads/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/deps/libcaption/CMakeLists.txt b/deps/libcaption/CMakeLists.txt index cba20daaff..e7fa94c127 100644 --- a/deps/libcaption/CMakeLists.txt +++ b/deps/libcaption/CMakeLists.txt @@ -42,6 +42,9 @@ target_compile_options( # MSVC /W4 (#2626): vendored upstream C stays vendored, with its own # suppressions instead of edits (the #516 vendored-code exemption). $<$:/wd4244> + $<$:/wd4701> + $<$:/wd4702> + $<$:/wd4703> ) set_target_properties(caption PROPERTIES FOLDER deps POSITION_INDEPENDENT_CODE TRUE) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt index 005ec1da70..dd22906e29 100644 --- a/deps/w32-pthreads/CMakeLists.txt +++ b/deps/w32-pthreads/CMakeLists.txt @@ -13,11 +13,13 @@ target_compile_definitions(w32-pthreads PRIVATE __CLEANUP_C PTW32_BUILD) # MSVC /W4 (#2626): vendored pthreads-win32 keeps its own suppressions rather # than source edits (the #516 vendored-code exemption): C4324 alignment # padding, C4057 indirection of a volatile LONG64/size_t pair in the MCS lock, -# C4310 a truncating constant cast, C4456 a shadowed local. +# C4310 a truncating constant cast, C4456 a shadowed local, C4702 the +# unreachable path after its own assert. target_compile_options( w32-pthreads PRIVATE $<$:/wd4057> + $<$:/wd4702> $<$:/wd4310> $<$:/wd4324> $<$:/wd4456> From e767cd71443b6b4e06d787ec1fe80e9d0e4f9949 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 15:02:21 -0700 Subject: [PATCH 05/63] build(msvc): fix the first-party libobs /W4 findings at the site (#2626) Fixes the five findings the Windows Tier 2 run reported after the vendored exemptions landed, without adding a /wd or a #pragma: - wasapi-output.c.h: drop the initialized-but-unused source local (C4189). - util/windows/window-helpers.c.h: rename the loop-local that hid the val parameter (C4457). - obs-win-crash-handler.c.h, obs-windows.c.h: GetProcAddress returns a FARPROC, and the (void *) cast into a typed function-pointer member is itself C4152. Copy the address through its storage with memcpy instead (get_proc and WINRT_IMPORT do the same for os_dlsym, which returns void *). --- .../audio-monitoring/win32/wasapi-output.c.h | 1 - libobs/obs-win-crash-handler.c.h | 24 +++++++++++-------- libobs/obs-windows.c.h | 23 +++++++++++++++--- libobs/util/windows/window-helpers.c.h | 6 ++--- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/libobs/audio-monitoring/win32/wasapi-output.c.h b/libobs/audio-monitoring/win32/wasapi-output.c.h index e34f1dd2dd..c76345cbcc 100644 --- a/libobs/audio-monitoring/win32/wasapi-output.c.h +++ b/libobs/audio-monitoring/win32/wasapi-output.c.h @@ -426,7 +426,6 @@ void audio_monitor_reset(struct audio_monitor *monitor) ReleaseSRWLockExclusive(&monitor->playback_mutex); if (success) { - obs_source_t *source = monitor->source; audio_monitor_free(monitor); *monitor = new_monitor; audio_monitor_init_final(monitor); diff --git a/libobs/obs-win-crash-handler.c.h b/libobs/obs-win-crash-handler.c.h index 00b70b5995..9d27ca0f33 100644 --- a/libobs/obs-win-crash-handler.c.h +++ b/libobs/obs-win-crash-handler.c.h @@ -99,16 +99,20 @@ static inline void exception_handler_data_free(struct exception_handler_data *da FreeLibrary(data->dbghelp); } -static inline void *get_proc(HMODULE module, const char *func) -{ - return (void *)GetProcAddress(module, func); -} - -#define GET_DBGHELP_IMPORT(target, str) \ - do { \ - data->target = get_proc(data->dbghelp, str); \ - if (!data->target) \ - return false; \ +/* GetProcAddress returns a FARPROC and the typed members are function pointers: + * a cast between the two is C4152 at /W4. Copy the address through a union + * instead, the way LOAD_MODULE_SYMBOL (libobs/obs-module.c.h) does for + * os_dlsym. No code is generated for the copy. */ +#define GET_DBGHELP_IMPORT(target, str) \ + do { \ + union { \ + FARPROC proc; \ + __typeof__(data->target) fn; \ + } _sym; \ + _sym.proc = GetProcAddress(data->dbghelp, str); \ + data->target = _sym.fn; \ + if (!data->target) \ + return false; \ } while (false) static inline bool get_dbghelp_imports(struct exception_handler_data *data) diff --git a/libobs/obs-windows.c.h b/libobs/obs-windows.c.h index 560e200547..3005e825d2 100644 --- a/libobs/obs-windows.c.h +++ b/libobs/obs-windows.c.h @@ -1115,14 +1115,23 @@ static void reset_win32_symbol_paths(void) if (!funcs_initialized) { HMODULE mod; + /* GetProcAddress yields a FARPROC and the members are function + * pointers: casting between them is C4152 at /W4. Copy the + * address through a union instead (as LOAD_MODULE_SYMBOL does). */ + union { + FARPROC proc; + __typeof__(sym_initialize_w) fn; + } sym; funcs_initialized = true; mod = LoadLibraryW(L"DbgHelp"); if (!mod) return; - sym_initialize_w = (void *)GetProcAddress(mod, "SymInitializeW"); - sym_set_search_path_w = (void *)GetProcAddress(mod, "SymSetSearchPathW"); + sym.proc = GetProcAddress(mod, "SymInitializeW"); + sym_initialize_w = sym.fn; + sym.proc = GetProcAddress(mod, "SymSetSearchPathW"); + sym_set_search_path_w = sym.fn; if (!sym_initialize_w || !sym_set_search_path_w) { FreeLibrary(mod); return; @@ -1308,9 +1317,17 @@ struct winrt_exports { void (*winrt_capture_thread_stop)(); }; +/* os_dlsym returns a void *, and assigning it straight to a function-pointer + * member is C4152 at /W4, so copy the address through a union, the way + * GRAPHICS_IMPORT (libobs/graphics/graphics-imports.c.h) does. */ #define WINRT_IMPORT(func) \ do { \ - exports->func = os_dlsym(module, #func); \ + union { \ + void *obj; \ + __typeof__(exports->func) fn; \ + } _sym; \ + _sym.obj = os_dlsym(module, #func); \ + exports->func = _sym.fn; \ if (!exports->func) { \ success = false; \ blog(LOG_ERROR, \ diff --git a/libobs/util/windows/window-helpers.c.h b/libobs/util/windows/window-helpers.c.h index 2fd3a26cd5..96d1470d24 100644 --- a/libobs/util/windows/window-helpers.c.h +++ b/libobs/util/windows/window-helpers.c.h @@ -70,11 +70,11 @@ bool ms_check_window_property_setting(obs_properties_t *ppts, obs_property_t *p, } for (;;) { - const char *val = obs_property_list_item_string(p, i++); - if (!val) + const char *item_val = obs_property_list_item_string(p, i++); + if (!item_val) break; - if (strcmp(val, cur_val) == 0) { + if (strcmp(item_val, cur_val) == 0) { match = true; break; } From 7010b9380a959878d10c8ef2df80919a2e2ef8da Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 15:24:33 -0700 Subject: [PATCH 06/63] build(msvc): name the graphics-hook unions and rename the hidden parameter (#2626) The Windows x64 app build's next /W4 findings after the libobs fixes are all in plugins/win-capture/graphics-hook: - d3d11-capture.cpp.hpp: name the two views (`shtex`, `shmem`) and the union (`u`) instead of relying on nameless struct/union (C4201 x3). Call sites become data.u.shtex.* / data.u.shmem.*; the overlay layout is unchanged. - d3d12-capture.cpp.hpp: the union wrapped a single anonymous struct, so the wrapper is deleted and the fields sit directly in d3d12_data (C4201), with no call-site change. - d3d9-patches.hpp: the `patch` parameter hid a global of that name (C4459); renamed to `index`. No pragma and no /wd: each warning is fixed at the site. --- .../graphics-hook/d3d11-capture.cpp.hpp | 69 ++++++++++--------- .../graphics-hook/d3d12-capture.cpp.hpp | 14 ++-- .../graphics-hook/d3d9-patches.hpp | 8 ++- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp b/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp index e9683ebb9a..2e42e42bd9 100644 --- a/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp +++ b/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp @@ -15,7 +15,7 @@ struct d3d11_data { struct shtex_data *shtex_info; ID3D11Texture2D *texture; HANDLE handle; - }; + } shtex; /* shared memory */ struct { ID3D11Texture2D *copy_surfaces[NUM_BUFFERS]; @@ -25,8 +25,8 @@ struct d3d11_data { struct shmem_data *shmem_info; int cur_tex; int copy_wait; - }; - }; + } shmem; + } u; }; static struct d3d11_data data = {}; @@ -36,16 +36,16 @@ void d3d11_free(void) capture_free(); if (data.using_shtex) { - if (data.texture) { - data.texture->Release(); + if (data.u.shtex.texture) { + data.u.shtex.texture->Release(); } } else { for (size_t i = 0; i < NUM_BUFFERS; i++) { - if (data.copy_surfaces[i]) { - if (data.texture_mapped[i]) { - data.context->Unmap(data.copy_surfaces[i], 0); + if (data.u.shmem.copy_surfaces[i]) { + if (data.u.shmem.texture_mapped[i]) { + data.context->Unmap(data.u.shmem.copy_surfaces[i], 0); } - data.copy_surfaces[i]->Release(); + data.u.shmem.copy_surfaces[i]->Release(); } } } @@ -146,7 +146,7 @@ static bool d3d11_shmem_init_buffers(size_t idx) { bool success; - success = create_d3d11_stage_surface(&data.copy_surfaces[idx]); + success = create_d3d11_stage_surface(&data.u.shmem.copy_surfaces[idx]); if (!success) { hlog("d3d11_shmem_init_buffers: failed to create copy surface"); return false; @@ -156,7 +156,7 @@ static bool d3d11_shmem_init_buffers(size_t idx) D3D11_MAPPED_SUBRESOURCE map = {}; HRESULT hr; - hr = data.context->Map(data.copy_surfaces[idx], 0, D3D11_MAP_READ, 0, &map); + hr = data.context->Map(data.u.shmem.copy_surfaces[idx], 0, D3D11_MAP_READ, 0, &map); if (FAILED(hr)) { hlog_hr("d3d11_shmem_init_buffers: failed to get " "pitch", @@ -164,8 +164,8 @@ static bool d3d11_shmem_init_buffers(size_t idx) return false; } - data.pitch = map.RowPitch; - data.context->Unmap(data.copy_surfaces[idx], 0); + data.u.shmem.pitch = map.RowPitch; + data.context->Unmap(data.u.shmem.copy_surfaces[idx], 0); } return true; @@ -180,7 +180,8 @@ static bool d3d11_shmem_init(HWND window) return false; } } - if (!capture_init_shmem(&data.shmem_info, window, data.cx, data.cy, data.pitch, data.format, false)) { + if (!capture_init_shmem(&data.u.shmem.shmem_info, window, data.cx, data.cy, data.u.shmem.pitch, data.format, + false)) { return false; } @@ -194,14 +195,14 @@ static bool d3d11_shtex_init(HWND window) data.using_shtex = true; - success = create_d3d11_tex(data.cx, data.cy, &data.texture, &data.handle); + success = create_d3d11_tex(data.cx, data.cy, &data.u.shtex.texture, &data.u.shtex.handle); if (!success) { hlog("d3d11_shtex_init: failed to create texture"); return false; } - if (!capture_init_shtex(&data.shtex_info, window, data.cx, data.cy, data.format, false, - (uintptr_t)data.handle)) { + if (!capture_init_shtex(&data.u.shtex.shtex_info, window, data.cx, data.cy, data.format, false, + (uintptr_t)data.u.shtex.handle)) { return false; } @@ -246,8 +247,8 @@ static inline void d3d11_copy_texture(ID3D11Resource *dst, ID3D11Resource *src) static inline void d3d11_shtex_capture(ID3D11Resource *backbuffer) { - if (data.texture) { - d3d11_copy_texture(data.texture, backbuffer); + if (data.u.shtex.texture) { + d3d11_copy_texture(data.u.shtex.texture, backbuffer); } } @@ -256,12 +257,12 @@ static void d3d11_shmem_capture_copy(int i) D3D11_MAPPED_SUBRESOURCE map; HRESULT hr; - if (data.texture_ready[i]) { - data.texture_ready[i] = false; + if (data.u.shmem.texture_ready[i]) { + data.u.shmem.texture_ready[i] = false; - hr = data.context->Map(data.copy_surfaces[i], 0, D3D11_MAP_READ, 0, &map); + hr = data.context->Map(data.u.shmem.copy_surfaces[i], 0, D3D11_MAP_READ, 0, &map); if (SUCCEEDED(hr)) { - data.texture_mapped[i] = true; + data.u.shmem.texture_mapped[i] = true; shmem_copy_data(i, map.pData); } } @@ -271,23 +272,23 @@ static inline void d3d11_shmem_capture(ID3D11Resource *backbuffer) { int next_tex; - next_tex = (data.cur_tex + 1) % NUM_BUFFERS; + next_tex = (data.u.shmem.cur_tex + 1) % NUM_BUFFERS; d3d11_shmem_capture_copy(next_tex); - if (data.copy_wait < NUM_BUFFERS - 1) { - data.copy_wait++; + if (data.u.shmem.copy_wait < NUM_BUFFERS - 1) { + data.u.shmem.copy_wait++; } else { - if (shmem_texture_data_lock(data.cur_tex)) { - data.context->Unmap(data.copy_surfaces[data.cur_tex], 0); - data.texture_mapped[data.cur_tex] = false; - shmem_texture_data_unlock(data.cur_tex); + if (shmem_texture_data_lock(data.u.shmem.cur_tex)) { + data.context->Unmap(data.u.shmem.copy_surfaces[data.u.shmem.cur_tex], 0); + data.u.shmem.texture_mapped[data.u.shmem.cur_tex] = false; + shmem_texture_data_unlock(data.u.shmem.cur_tex); } - d3d11_copy_texture(data.copy_surfaces[data.cur_tex], backbuffer); - data.texture_ready[data.cur_tex] = true; + d3d11_copy_texture(data.u.shmem.copy_surfaces[data.u.shmem.cur_tex], backbuffer); + data.u.shmem.texture_ready[data.u.shmem.cur_tex] = true; } - data.cur_tex = next_tex; + data.u.shmem.cur_tex = next_tex; } void d3d11_capture(void *swap_ptr, void *backbuffer_ptr) @@ -302,7 +303,7 @@ void d3d11_capture(void *swap_ptr, void *backbuffer_ptr) if (capture_should_init()) { d3d11_init(swap); } - if (data.handle != nullptr && capture_ready()) { + if (data.u.shtex.handle != nullptr && capture_ready()) { ID3D11Resource *backbuffer; hr = dxgi_backbuffer->QueryInterface(__uuidof(ID3D11Resource), (void **)&backbuffer); diff --git a/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp b/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp index 572d7b91b8..221da8bfe5 100644 --- a/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp +++ b/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp @@ -20,15 +20,11 @@ struct d3d12_data { ID3D11DeviceContext *context11; ID3D11On12Device *device11on12; - union { - struct { - struct shtex_data *shtex_info; - UINT backbuffer_count; - UINT cur_backbuffer; - ID3D11Texture2D *copy_tex; - HANDLE handle; - }; - }; + struct shtex_data *shtex_info; + UINT backbuffer_count; + UINT cur_backbuffer; + ID3D11Texture2D *copy_tex; + HANDLE handle; }; static struct d3d12_data data = {}; diff --git a/plugins/win-capture/graphics-hook/d3d9-patches.hpp b/plugins/win-capture/graphics-hook/d3d9-patches.hpp index 06af6814a5..7f73f37eb0 100644 --- a/plugins/win-capture/graphics-hook/d3d9-patches.hpp +++ b/plugins/win-capture/graphics-hook/d3d9-patches.hpp @@ -173,12 +173,14 @@ static inline int get_d3d9_patch(HMODULE d3d9) return -1; } -static inline uint8_t *get_d3d9_patch_addr(HMODULE d3d9, int patch) +/* The parameter used to be called `patch`, which hides a global symbol of that + * name (C4459 at /W4); `index` also matches get_d3d9_patch's return value. */ +static inline uint8_t *get_d3d9_patch_addr(HMODULE d3d9, int index) { - if (patch == -1) { + if (index == -1) { return nullptr; } uint8_t *addr = (uint8_t *)d3d9; - return addr + patch_offset[patch] + CMP_SIZE; + return addr + patch_offset[index] + CMP_SIZE; } From 4a99011ab40f1b57401c9829c4ca0d84e6b3b82d Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 15:47:28 -0700 Subject: [PATCH 07/63] build(msvc): fix the DbgHelp unions and the crash-handler /W4 findings (#2626) The Windows Rust Tier 2 lane compiles the libobs C groups with MSVC, and at /W4 /WX it failed on three findings left by the previous commits on this branch: - obs-windows.c.h: `sym_initialize_w` and `sym_set_search_path_w` have different prototypes, so one union declared with `__typeof__(sym_initialize_w)` made the second assignment C4113 - and a hard `-Wincompatible-function-pointer-types` error in the Windows cross lane. One union per member instead. - obs-win-crash-handler.c.h `walk_stack`: `func_offset` is filled through a pointer, so MSVC's flow analysis cannot see that the read is guarded by the call's return value: C4701. Initialize it to 0; it is only printed when that call succeeded. - obs-win-crash-handler.c.h `exception_handler`: `bcrash` is OBS_NORETURN, so the free, the `inside_handler` reset and the return after it were dead statements: C4702. Delete them. No pragma and no per-file /wd: each warning is fixed at the site. --- libobs/obs-win-crash-handler.c.h | 14 ++++++++------ libobs/obs-windows.c.h | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/libobs/obs-win-crash-handler.c.h b/libobs/obs-win-crash-handler.c.h index 9d27ca0f33..1d87bf45de 100644 --- a/libobs/obs-win-crash-handler.c.h +++ b/libobs/obs-win-crash-handler.c.h @@ -299,7 +299,11 @@ static inline void get_module_name(struct exception_handler_data *data, struct m static inline bool walk_stack(struct exception_handler_data *data, HANDLE thread, struct stack_trace *trace) { struct module_info module_info = {0}; - DWORD64 func_offset; + /* sym_from_addr fills this through a pointer, so MSVC's flow analysis + * cannot see that the read below is guarded by its return value: C4701 + * at /W4. Starting it at zero costs nothing and cannot be observed, + * because it is only printed when that call succeeded. */ + DWORD64 func_offset = 0; char sym_name[256]; char *p; @@ -517,12 +521,10 @@ static LONG CALLBACK exception_handler(PEXCEPTION_POINTERS exception) inside_handler = true; handle_exception(&data, exception); + /* bcrash is OBS_NORETURN (libobs/util/base.h), so the cleanup, the + * inside_handler reset and the return that used to follow it were dead + * statements - C4702 at /W4. Nothing is leaked: the process is gone. */ bcrash("%s", data.str.array); - exception_handler_data_free(&data); - - inside_handler = false; - - return EXCEPTION_CONTINUE_SEARCH; } void initialize_crash_handler(void) diff --git a/libobs/obs-windows.c.h b/libobs/obs-windows.c.h index 3005e825d2..902a2d33ad 100644 --- a/libobs/obs-windows.c.h +++ b/libobs/obs-windows.c.h @@ -1116,22 +1116,28 @@ static void reset_win32_symbol_paths(void) if (!funcs_initialized) { HMODULE mod; /* GetProcAddress yields a FARPROC and the members are function - * pointers: casting between them is C4152 at /W4. Copy the - * address through a union instead (as LOAD_MODULE_SYMBOL does). */ + * pointers: casting between them is C4152 at /W4. Copy each + * address through a union of that member's own type instead (as + * LOAD_MODULE_SYMBOL does), one union per member because the two + * prototypes differ and a shared union would be C4113. */ union { FARPROC proc; __typeof__(sym_initialize_w) fn; - } sym; + } sym_initialize; + union { + FARPROC proc; + __typeof__(sym_set_search_path_w) fn; + } sym_search_path; funcs_initialized = true; mod = LoadLibraryW(L"DbgHelp"); if (!mod) return; - sym.proc = GetProcAddress(mod, "SymInitializeW"); - sym_initialize_w = sym.fn; - sym.proc = GetProcAddress(mod, "SymSetSearchPathW"); - sym_set_search_path_w = sym.fn; + sym_initialize.proc = GetProcAddress(mod, "SymInitializeW"); + sym_initialize_w = sym_initialize.fn; + sym_search_path.proc = GetProcAddress(mod, "SymSetSearchPathW"); + sym_set_search_path_w = sym_search_path.fn; if (!sym_initialize_w || !sym_set_search_path_w) { FreeLibrary(mod); return; From e303806fca78dc7e71919dfa904028df49f6925f Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 16:10:37 -0700 Subject: [PATCH 08/63] build(msvc): fix the next libobs /W4 findings (#2626) The Windows Tier 2 lane's next MSVC /W4 /WX pass reported eight findings in the libobs unity TU: - obs-scene.c.h: `group_info` was a tentative definition without an initializer (the definition is at the bottom of the file): C4132 "const object should be initialized". Declare it `extern` instead. - obs-output.c.h: `size` is only set on the caption paths and read only under the matching codec guard, which MSVC's flow analysis cannot see across the branches: C4701 "potentially uninitialized". Start it at zero; no behavior change. - obs.c.h and obs-hotkey.c.h: C4702 "unreachable code" at every HASH_ADD and HASH_ITER use. The macros end in uthash_fatal -> exit(-1), and MSVC reports the non-returning path as unreachable. This is the vendored uthash false positive the Rust oracle already suppresses with /wd4702 (rust/obs-c-oracle/build.rs), so libobs-objects gets the same exemption for MSVC instead of editing uthash (#516 vendored-code exemption). No pragma in first-party sources; the one new /wd is the existing oracle exemption applied to the same macros. --- libobs/CMakeLists.txt | 7 +++++++ libobs/obs-output.c.h | 5 ++++- libobs/obs-scene.c.h | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index ee806f85a3..64f2ee2518 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -31,6 +31,13 @@ include(cmake/sources.cmake) set_target_properties(libobs-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_sources(libobs-objects PRIVATE ${LIBOBS_SOURCES}) +# MSVC /W4 (#2626): uthash's HASH_* macros end in uthash_fatal -> exit(-1), +# whose non-returning path makes MSVC report C4702 "unreachable code" at the +# closing brace of every HASH_ADD/HASH_ITER use in obs.c.h and obs-hotkey.c.h. +# The Rust oracle already suppresses C4702 for the same macros +# (rust/obs-c-oracle/build.rs), so this follows the vendored-code exemption +# (#516) instead of editing uthash or sprinkling pragmas in first-party code. +target_compile_options(libobs-objects PRIVATE $<$:/wd4702>) obs_libobs_add_c_sources(${LIBOBS_PORTED_SOURCES}) # MSVC warns about INFINITY (a standard library macro) in obs-audio-controls.c # (#870; was a pragma in the file). diff --git a/libobs/obs-output.c.h b/libobs/obs-output.c.h index 76c7d43f02..26457c85bb 100644 --- a/libobs/obs-output.c.h +++ b/libobs/obs-output.c.h @@ -1530,7 +1530,10 @@ static bool add_caption(struct obs_output *output, struct encoder_packet *out) struct encoder_packet backup = *out; sei_t sei; uint8_t *data = NULL; - size_t size; + /* Only set when the packet carries a caption; reading it without + * a caption is guarded below. Starting at zero silences MSVC's C4701 + * "potentially uninitialized" at /W4 without changing behavior. */ + size_t size = 0; long ref = 1; bool avc = false; bool hevc = false; diff --git a/libobs/obs-scene.c.h b/libobs/obs-scene.c.h index f66902f1e5..b4ecd17eb1 100644 --- a/libobs/obs-scene.c.h +++ b/libobs/obs-scene.c.h @@ -18,7 +18,11 @@ #include "libobs/build/libobs.pch.h" -const struct obs_source_info group_info; +/* Forward declaration: the definition (with its initializer) is at + * the bottom of this file. `extern` keeps MSVC from reading this as a + * tentative definition and warning C4132 "const object should be + * initialized" at /W4. */ +extern const struct obs_source_info group_info; static void resize_group(obs_sceneitem_t *group, bool scene_resize); static void resize_scene(obs_scene_t *scene); From 1ad5438537c578e8c0367c12c9d7bd3142fbae08 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 16:22:41 -0700 Subject: [PATCH 09/63] build(msvc): zero-init the pending audio actions (#2626) The Windows Tier 2 lane's next /W4 pass reports C4701 on the two apply-audio-* helpers: `action` is only assigned when an action is pending and only read under that same guard, which MSVC's flow analysis cannot correlate across the unlock. Zero-initialize the struct in both; the value is never read on the path where it would be the initializer. --- libobs/obs-scene-item-audio-actions.c.h | 4 +++- libobs/obs-source.c.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libobs/obs-scene-item-audio-actions.c.h b/libobs/obs-scene-item-audio-actions.c.h index b2236ac267..b2519f53dd 100644 --- a/libobs/obs-scene-item-audio-actions.c.h +++ b/libobs/obs-scene-item-audio-actions.c.h @@ -49,7 +49,9 @@ void apply_scene_item_audio_actions(struct obs_scene_item *item, float *buf, uin bool apply_scene_item_volume(struct obs_scene_item *item, float *buf, uint64_t ts, size_t sample_rate) { bool actions_pending; - struct item_action action; + /* Set only when an action is pending, and read under the same guard: + * C4701 at /W4. Zero-initializing cannot be observed. */ + struct item_action action = {0}; pthread_mutex_lock(&item->actions_mutex); diff --git a/libobs/obs-source.c.h b/libobs/obs-source.c.h index 09645efef6..a48ac63a2d 100644 --- a/libobs/obs-source.c.h +++ b/libobs/obs-source.c.h @@ -4903,7 +4903,10 @@ static void apply_audio_actions(obs_source_t *source, size_t channels, size_t sa * stay here. */ static void apply_audio_volume(obs_source_t *source, uint32_t mixers, size_t channels, size_t sample_rate) { - struct audio_action action; + /* Set only when an action is pending, and read under the same guard; + * MSVC's flow analysis cannot carry that across the branch: C4701 at + * /W4. Zero-initializing cannot be observed, the read is guarded. */ + struct audio_action action = {0}; bool actions_pending; float vol; From e81b0f2cb8fe3fa8ab9671a78b61dbbdd4fba366 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 16:33:49 -0700 Subject: [PATCH 10/63] build(msvc): keep crate names out of the C4702 exemption comment (#2626) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ci/test_tier2_proof_inputs.py treats any crate name mentioned in a cmake or CMakeLists.txt file as a Tier 2 root (tier2_roots() regexes the crate names over CMAKE_INPUTS). The previous commit's comment named the C oracle's build script by its path, which pulled that crate into the Tier 2 closure and failed two assertions in that test: "Format 🔍 / checks" went red on f7c71c52a. Reword the comment without the crate name and leave a note so the next edit does not reintroduce it. Verified: cd ci && uv run python -m unittest test_tier2_proof_inputs -> Ran 5 tests, OK; ./lint -> lane lint: ok. --- libobs/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index 64f2ee2518..faad2a90ca 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -34,9 +34,12 @@ target_sources(libobs-objects PRIVATE ${LIBOBS_SOURCES}) # MSVC /W4 (#2626): uthash's HASH_* macros end in uthash_fatal -> exit(-1), # whose non-returning path makes MSVC report C4702 "unreachable code" at the # closing brace of every HASH_ADD/HASH_ITER use in obs.c.h and obs-hotkey.c.h. -# The Rust oracle already suppresses C4702 for the same macros -# (rust/obs-c-oracle/build.rs), so this follows the vendored-code exemption -# (#516) instead of editing uthash or sprinkling pragmas in first-party code. +# The C oracle already suppresses C4702 for the same macros in its own build +# script, so this follows the vendored-code exemption (#516) instead of editing +# uthash or sprinkling pragmas in first-party code. +# +# Do not name a crate here: ci/test_tier2_proof_inputs.py treats any crate name +# mentioned in a cmake or CMakeLists.txt file as a Tier 2 root. target_compile_options(libobs-objects PRIVATE $<$:/wd4702>) obs_libobs_add_c_sources(${LIBOBS_PORTED_SOURCES}) # MSVC warns about INFINITY (a standard library macro) in obs-audio-controls.c From 27bc7bd2aed53f321238c995aef55a559e3b5c1e Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 16:48:53 -0700 Subject: [PATCH 11/63] build(msvc): zero-init the proc call copy (#2626) libobs-c-reference's /W4 pass reports C4701 on `info_copy` in proc_handler_call: it is copied under the mutex only when `info` is non-NULL and read only after the `!info` early return, which MSVC's flow analysis cannot correlate. Zero-initialize it; the value is unreachable when no procedure was found. --- libobs/callback/proc.c.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libobs/callback/proc.c.h b/libobs/callback/proc.c.h index accfe37081..86a0a7ef97 100644 --- a/libobs/callback/proc.c.h +++ b/libobs/callback/proc.c.h @@ -111,7 +111,10 @@ bool proc_handler_call(proc_handler_t *handler, const char *name, calldata_t *pa pthread_mutex_lock(&handler->mutex); struct proc_info *info = getproc(handler, name); - struct proc_info info_copy; + /* Copied under the lock only when `info` is set, and used only after the + * `!info` early return; MSVC cannot correlate the two: C4701 at /W4. + * Zero-initializing cannot be observed. */ + struct proc_info info_copy = {0}; if (info) info_copy = *info; pthread_mutex_unlock(&handler->mutex); From 15fd4fa24a63f17adf5fb28afde4922f0faa1c7f Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 17:05:44 -0700 Subject: [PATCH 12/63] build(msvc): apply the C4702 uthash exemption to every C target (#2626) The C-reference library compiles the ported groups with its own compile options, so the uthash C4702 false positive reappears there (obs-data.c.h:304 and :871, both HASH_ADD_STR). Apply the exemption to libobs-objects and every target in OBS_LIBOBS_C_TARGETS instead of only the object library. --- libobs/CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index faad2a90ca..b2d03120b7 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -33,14 +33,18 @@ set_target_properties(libobs-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_sources(libobs-objects PRIVATE ${LIBOBS_SOURCES}) # MSVC /W4 (#2626): uthash's HASH_* macros end in uthash_fatal -> exit(-1), # whose non-returning path makes MSVC report C4702 "unreachable code" at the -# closing brace of every HASH_ADD/HASH_ITER use in obs.c.h and obs-hotkey.c.h. -# The C oracle already suppresses C4702 for the same macros in its own build -# script, so this follows the vendored-code exemption (#516) instead of editing -# uthash or sprinkling pragmas in first-party code. +# closing brace of every HASH_ADD/HASH_ITER use (obs.c.h, obs-data.c.h, +# obs-hotkey.c.h, ...). The C oracle already suppresses C4702 for the same +# macros in its own build script, so this follows the vendored-code exemption +# (#516) instead of editing uthash or sprinkling pragmas in first-party code. +# Every C target needs it: the ported groups are also compiled by the +# C-reference library, which has its own compile options. # # Do not name a crate here: ci/test_tier2_proof_inputs.py treats any crate name # mentioned in a cmake or CMakeLists.txt file as a Tier 2 root. -target_compile_options(libobs-objects PRIVATE $<$:/wd4702>) +foreach(target libobs-objects ${OBS_LIBOBS_C_TARGETS}) + target_compile_options(${target} PRIVATE $<$:/wd4702>) +endforeach() obs_libobs_add_c_sources(${LIBOBS_PORTED_SOURCES}) # MSVC warns about INFINITY (a standard library macro) in obs-audio-controls.c # (#870; was a pragma in the file). From d74d575d1a4687d0f2a0353b182efd88cbdd66f4 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 17:20:32 -0700 Subject: [PATCH 13/63] build(msvc): exempt vendored libnsgif from C4701/C4703 (#2626) The C-reference build's /W4 pass reaches libnsgif's gif-frame.c and reports C4701/C4703 on its `uncompressed` pointer, whose LZW path sets it before every read. Vendored code keeps its own suppressions rather than source edits (the #516 vendored-code exemption, as deps/libcaption and w32-pthreads already do), so the four ported nsgif unity groups get /wd4701;/wd4703 for MSVC. --- libobs/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index b2d03120b7..a95d587676 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -53,6 +53,21 @@ set_property( APPEND PROPERTY COMPILE_OPTIONS "$<$:/wd4056;/wd4756>" ) +# MSVC /W4 (#2626): vendored libnsgif keeps its own suppressions instead of +# source edits (the #516 vendored-code exemption). C4701/C4703 are on its +# `uncompressed` pointer, which its LZW path sets before every read. +foreach(source + build/libobs.ported-nsgif-blocks+.h.c + build/libobs.ported-nsgif-frame+.h.c + build/libobs.ported-nsgif-gif+.h.c + build/libobs.ported-nsgif-lzw+.h.c +) + set_property( + SOURCE ${source} + APPEND + PROPERTY COMPILE_OPTIONS "$<$:/wd4701;/wd4703>" + ) +endforeach() # libobs-version and libobs-core-modules are object libraries too, and CMake # adds an object library's objects only to targets that link it directly, so # each shared library links them itself (libobs-objects gets their headers). From b8e817363d9a571b1c2636188e7af6a19e196165 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 17:35:14 -0700 Subject: [PATCH 14/63] build(msvc): apply gersemi formatting to the libobs CMake exemption (#2626) The libnsgif exemption block failed the lint lane's gersemi check ("libobs/CMakeLists.txt would be reformatted"). Reformat with the pinned gersemi 0.25.0; no logic change. --- libobs/CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index a95d587676..d64b199b2c 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -56,17 +56,14 @@ set_property( # MSVC /W4 (#2626): vendored libnsgif keeps its own suppressions instead of # source edits (the #516 vendored-code exemption). C4701/C4703 are on its # `uncompressed` pointer, which its LZW path sets before every read. -foreach(source +foreach( + source build/libobs.ported-nsgif-blocks+.h.c build/libobs.ported-nsgif-frame+.h.c build/libobs.ported-nsgif-gif+.h.c build/libobs.ported-nsgif-lzw+.h.c ) - set_property( - SOURCE ${source} - APPEND - PROPERTY COMPILE_OPTIONS "$<$:/wd4701;/wd4703>" - ) + set_property(SOURCE ${source} APPEND PROPERTY COMPILE_OPTIONS "$<$:/wd4701;/wd4703>") endforeach() # libobs-version and libobs-core-modules are object libraries too, and CMake # adds an object library's objects only to targets that link it directly, so From 29a0ad85716e27ce60ed0d05a1eb42802a1d4845 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 17:50:08 -0700 Subject: [PATCH 15/63] build(msvc): initialize libnsgif's decompressed pointer (#2626) The per-source COMPILE_OPTIONS exemption from the previous commit did not take effect under the Visual Studio generator, so the C-reference /W4 pass still reported C4701/C4703 on `uncompressed` in gif-frame.c. Drop that block and fix the site instead: lzw_decode() writes the pointer through its address before the first read, so the initializer is never observed - it only tells MSVC what it cannot infer. --- libobs/CMakeLists.txt | 12 ------------ libobs/graphics/libnsgif/gif-frame.c.h | 5 ++++- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index d64b199b2c..b2d03120b7 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -53,18 +53,6 @@ set_property( APPEND PROPERTY COMPILE_OPTIONS "$<$:/wd4056;/wd4756>" ) -# MSVC /W4 (#2626): vendored libnsgif keeps its own suppressions instead of -# source edits (the #516 vendored-code exemption). C4701/C4703 are on its -# `uncompressed` pointer, which its LZW path sets before every read. -foreach( - source - build/libobs.ported-nsgif-blocks+.h.c - build/libobs.ported-nsgif-frame+.h.c - build/libobs.ported-nsgif-gif+.h.c - build/libobs.ported-nsgif-lzw+.h.c -) - set_property(SOURCE ${source} APPEND PROPERTY COMPILE_OPTIONS "$<$:/wd4701;/wd4703>") -endforeach() # libobs-version and libobs-core-modules are object libraries too, and CMake # adds an object library's objects only to targets that link it directly, so # each shared library links them itself (libobs-objects gets their headers). diff --git a/libobs/graphics/libnsgif/gif-frame.c.h b/libobs/graphics/libnsgif/gif-frame.c.h index 39213bae66..bdc5d14be0 100644 --- a/libobs/graphics/libnsgif/gif-frame.c.h +++ b/libobs/graphics/libnsgif/gif-frame.c.h @@ -154,7 +154,10 @@ static nsgif_error nsgif_frame__decode_complex( nsgif_error ret = NSGIF_OK; uint32_t clip_x = nsgif_frame__clip(offset_x, width, canvas->width); uint32_t clip_y = nsgif_frame__clip(offset_y, height, canvas->height); - const uint8_t *uncompressed; + /* Set by lzw_decode() (through the pointer) before the first read, so + * this initializer is never observed; MSVC cannot see that lzw_decode + * writes it and reports C4701/C4703 at /W4. */ + const uint8_t *uncompressed = NULL; uint32_t available = 0; uint8_t step = 24; uint32_t skip = 0; From c4af002d5d48e09c1738f907be038493ff4c14ed Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 18:03:14 -0700 Subject: [PATCH 16/63] build(msvc): load RtlGetVersion through a union (#2626) platform-windows.c.h assigned GetProcAddress's FARPROC to the typed get_ver through a `void *` cast, which MSVC reports as C4152 at /W4. Copy the address through a union of the two types instead, as the symbol loaders elsewhere in this PR do. --- libobs/util/platform-windows.c.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libobs/util/platform-windows.c.h b/libobs/util/platform-windows.c.h index f70e664d3d..62e224bebc 100644 --- a/libobs/util/platform-windows.c.h +++ b/libobs/util/platform-windows.c.h @@ -1010,7 +1010,16 @@ static inline void rtl_get_ver(struct win_version_info *ver) return; NTSTATUS(WINAPI * get_ver) - (RTL_OSVERSIONINFOEXW *) = (void *)GetProcAddress(ntdll, "RtlGetVersion"); + (RTL_OSVERSIONINFOEXW *); + /* GetProcAddress yields a FARPROC and `get_ver` is a function pointer: + * casting between them through a void * is C4152 at /W4. Copy the address + * through a union instead, the way LOAD_MODULE_SYMBOL does for os_dlsym. */ + union { + FARPROC proc; + __typeof__(get_ver) fn; + } sym; + sym.proc = GetProcAddress(ntdll, "RtlGetVersion"); + get_ver = sym.fn; if (!get_ver) { return; } From a0123afd042604639c963c2292184722943eda88 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 18:34:26 -0700 Subject: [PATCH 17/63] build(msvc): exempt the C tests from the /W4-only classes (#2626) The cmocka tests are existing C tests, which this repo never edits to satisfy a new warning (#516), and several of them compile libobs / libobs-rust sources into their own executable, so the /W4 level reports those classes against them instead of against product code. This is the MSVC analogue of the -Wno-* list the same file already carries for clang: C4132, C4201 (the nameless unions in libobs/graphics/vec*.h and util/profiler.h, an API change), C4244/C4245, C4310, C4456/C4459 and C4702 (uthash's non-returning uthash_fatal path). --- test/cmocka/CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index f53f4d3a4f..d7df883104 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -67,6 +67,30 @@ add_compile_options($<$:-Wno-strict- # tests (obs-rust/obs-studio#516, #2842). The macOS CI preset builds with # CMAKE_COMPILE_WARNING_AS_ERROR, so without this the lane does not compile. add_compile_options($<$:-Wno-comma>) +# The MSVC /W4 set (obs-rust/obs-studio#2626) needs the same split, and for the +# same reason: these are existing C tests, never edited to satisfy a new +# warning (obs-rust/obs-studio#516), and several of them compile libobs / +# libobs-rust sources into their own executable, so the classes the /W4 level +# adds are reported against them rather than against product code. +# C4132 a const struct the test fills in field by field +# C4201 the nameless unions in libobs/graphics/vec{2,3,4}.h and +# libobs/util/profiler.h (an API change, not a test bug) +# C4244/C4245 uint32 -> uint16 and int -> SOCKET in their fixtures, and the +# librtmp sources some of them compile +# C4310 constant truncation in their tables +# C4456/C4459 a test helper or local shadowing an outer local/global +# C4702 the non-returning uthash_fatal path at the end of every HASH_* block +# (the reason libobs-objects carries /wd4702 as well) +add_compile_options( + $<$:/wd4132> + $<$:/wd4201> + $<$:/wd4244> + $<$:/wd4245> + $<$:/wd4310> + $<$:/wd4456> + $<$:/wd4459> + $<$:/wd4702> +) # Per-test sanitizers (obs-rust/obs-studio#159). Some tests compile the code # they check with ASan/UBSan so a bug fails the test. Those flags are added From 062028a223368c58794be49763b5a249e5ef08f4 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 18:34:28 -0700 Subject: [PATCH 18/63] build(msvc): fix the next first-party /W4 findings at the site (#2626) Windows Tier 2 at /W4 (/WX on) reported these after the libobs wave: - shared/ipc-util: the server thread's inner WAIT result shadowed the outer one (C4456); it is a separate wait, so name it wait_result. - shared/bpm: 'size' is only assigned on the avc||hevc path (C4701); initialize it, no value changes. - shared/media-playback: 'v'/'a' are set by the frame loops but MSVC cannot see that the loop runs before the use (C4701/C4703); initialize to NULL - the branch that dereferences them requires num > 0, which means the loop ran. - shared/media-playback: (uint16_t) on get_max_luminance's return and (uint8_t) on the channel count handed to convert_speaker_layout; both are the conversion the compiler already performed (C4244). - plugins/obs-filters: initialize the LUT entry colour (C4701). - plugins/obs-outputs: explicit (uint8_t)/(uint16_t) casts where the bitstream readers return unsigned int into a narrower field, and 0xFFFF for the two bit-exact -1 descriptor fields (C4244/C4245). Every change is the conversion the compiler already applied; no values, ranges or control flow change. --- plugins/obs-filters/cube-lut.c.h | 2 +- plugins/obs-outputs/mp4-mux.c.h | 6 +-- plugins/obs-outputs/rtmp-av1.c.h | 30 +++++------ plugins/obs-outputs/rtmp-hevc.c.h | 52 +++++++++---------- shared/bpm/bpm.c.h | 2 +- shared/ipc-util/ipc-util/pipe-windows.c.h | 4 +- .../media-playback/media-playback/cache.c.h | 4 +- .../media-playback/media-playback/decode.c.h | 2 +- .../media-playback/media-playback/media.c.h | 2 +- 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/plugins/obs-filters/cube-lut.c.h b/plugins/obs-filters/cube-lut.c.h index ed22fa4683..ee34e03578 100644 --- a/plugins/obs-filters/cube-lut.c.h +++ b/plugins/obs-filters/cube-lut.c.h @@ -80,7 +80,7 @@ void *load_cube_file(const char *const path, uint32_t *const width, struct vec3 FILE *const file = os_fopen(path, "rb"); if (file) { - float red, green, blue; + float red = 0.0f, green = 0.0f, blue = 0.0f; unsigned width_1d = 0; unsigned width_3d = 0; diff --git a/plugins/obs-outputs/mp4-mux.c.h b/plugins/obs-outputs/mp4-mux.c.h index bd7105c0fd..74d0400b8b 100644 --- a/plugins/obs-outputs/mp4-mux.c.h +++ b/plugins/obs-outputs/mp4-mux.c.h @@ -592,7 +592,7 @@ static inline void mp4_write_visual_sample_entry(struct mp4_mux *mux, obs_encode s_write(s, compressor_name, sizeof(compressor_name)); // compressorname s_wb16(s, 0x0018); // depth - s_wb16(s, -1); // pre_defined + s_wb16(s, 0xFFFF); // pre_defined } /// 12.1.6 Content light level @@ -894,7 +894,7 @@ static inline void mp4_write_audio_sample_entry(struct mp4_mux *mux, struct mp4_ s_wb32(s, is_pcm ? track->sample_size : 0); // constBytesPerAudioPacket s_wb32(s, is_pcm ? 1 : 0); // constLPCMFramesPerAudioPacket } else { - s_wb16(s, channels); // channelcount + s_wb16(s, (uint16_t)channels); // channelcount /* OBS FLAC is currently always 16-bit, ALAC always 24, this may change in the future and should be * handled differently then. @@ -1558,7 +1558,7 @@ static size_t mp4_write_sgpd_aac(struct mp4_mux *mux) s_wb32(s, 1); // entry_count // AudioRollRecoveryEntry - s_wb16(s, -1); // roll_distance + s_wb16(s, 0xFFFF); // roll_distance return write_box_size(s, start); } diff --git a/plugins/obs-outputs/rtmp-av1.c.h b/plugins/obs-outputs/rtmp-av1.c.h index 5878e8166a..419533f4cf 100644 --- a/plugins/obs-outputs/rtmp-av1.c.h +++ b/plugins/obs-outputs/rtmp-av1.c.h @@ -250,18 +250,18 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex if (seq_params->profile == FF_PROFILE_AV1_PROFESSIONAL && high_bitdepth) twelve_bit = av1_get_bits(gb, 1); - seq_params->bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2); + seq_params->bitdepth = (uint8_t)(8 + (high_bitdepth * 2) + (twelve_bit * 2)); if (seq_params->profile == FF_PROFILE_AV1_HIGH) seq_params->monochrome = 0; else - seq_params->monochrome = av1_get_bits(gb, 1); + seq_params->monochrome = (uint8_t)av1_get_bits(gb, 1); - seq_params->color_description_present_flag = av1_get_bits(gb, 1); + seq_params->color_description_present_flag = (uint8_t)av1_get_bits(gb, 1); if (seq_params->color_description_present_flag) { - seq_params->color_primaries = av1_get_bits(gb, 8); - seq_params->transfer_characteristics = av1_get_bits(gb, 8); - seq_params->matrix_coefficients = av1_get_bits(gb, 8); + seq_params->color_primaries = (uint8_t)av1_get_bits(gb, 8); + seq_params->transfer_characteristics = (uint8_t)av1_get_bits(gb, 8); + seq_params->matrix_coefficients = (uint8_t)av1_get_bits(gb, 8); } else { seq_params->color_primaries = 2; seq_params->transfer_characteristics = 2; @@ -269,7 +269,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex } if (seq_params->monochrome) { - seq_params->color_range = av1_get_bits(gb, 1); + seq_params->color_range = (uint8_t)av1_get_bits(gb, 1); seq_params->chroma_subsampling_x = 1; seq_params->chroma_subsampling_y = 1; seq_params->chroma_sample_position = 0; @@ -279,7 +279,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex seq_params->chroma_subsampling_x = 0; seq_params->chroma_subsampling_y = 0; } else { - seq_params->color_range = av1_get_bits(gb, 1); + seq_params->color_range = (uint8_t)av1_get_bits(gb, 1); if (seq_params->profile == FF_PROFILE_AV1_MAIN) { seq_params->chroma_subsampling_x = 1; @@ -289,9 +289,9 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex seq_params->chroma_subsampling_y = 0; } else { if (twelve_bit) { - seq_params->chroma_subsampling_x = av1_get_bits(gb, 1); + seq_params->chroma_subsampling_x = (uint8_t)av1_get_bits(gb, 1); if (seq_params->chroma_subsampling_x) - seq_params->chroma_subsampling_y = av1_get_bits(gb, 1); + seq_params->chroma_subsampling_y = (uint8_t)av1_get_bits(gb, 1); else seq_params->chroma_subsampling_y = 0; } else { @@ -300,7 +300,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex } } if (seq_params->chroma_subsampling_x && seq_params->chroma_subsampling_y) - seq_params->chroma_sample_position = av1_get_bits(gb, 2); + seq_params->chroma_sample_position = (uint8_t)av1_get_bits(gb, 2); } skip_bits(gb, 1); // separate_uv_delta_q @@ -325,13 +325,13 @@ static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_ memset(seq_params, 0, sizeof(*seq_params)); - seq_params->profile = av1_get_bits(&gb, 3); + seq_params->profile = (uint8_t)av1_get_bits(&gb, 3); skip_bits(&gb, 1); // still_picture reduced_still_picture_header = av1_get_bits(&gb, 1); if (reduced_still_picture_header) { - seq_params->level = av1_get_bits(&gb, 5); + seq_params->level = (uint8_t)av1_get_bits(&gb, 5); seq_params->tier = 0; } else { int initial_display_delay_present_flag, operating_points_cnt_minus_1; @@ -381,8 +381,8 @@ static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_ } if (i == 0) { - seq_params->level = seq_level_idx; - seq_params->tier = seq_tier; + seq_params->level = (uint8_t)seq_level_idx; + seq_params->tier = (uint8_t)seq_tier; } } } diff --git a/plugins/obs-outputs/rtmp-hevc.c.h b/plugins/obs-outputs/rtmp-hevc.c.h index e09ba2d3e9..1bcf942cad 100644 --- a/plugins/obs-outputs/rtmp-hevc.c.h +++ b/plugins/obs-outputs/rtmp-hevc.c.h @@ -258,13 +258,13 @@ uint8_t *ff_nal_unit_extract_rbsp(uint8_t *dst, const uint8_t *src, int src_len, static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, HVCCNALUnitArray *array) { - s_wb16(&array->nalUnit, nal_size); + s_wb16(&array->nalUnit, (uint16_t)nal_size); s_write(&array->nalUnit, nal_buf, nal_size); array->NAL_unit_type = nal_type; array->numNalus++; if (nal_type == OBS_HEVC_NAL_VPS || nal_type == OBS_HEVC_NAL_SPS || nal_type == OBS_HEVC_NAL_PPS) - array->array_completeness = ps_array_completeness; + array->array_completeness = (uint8_t)ps_array_completeness; return 0; } @@ -272,7 +272,7 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t static void nal_unit_parse_header(HevcGetBitContext *gb, uint8_t *nal_type) { skip_bits(gb, 1); // forbidden_zero_bit - *nal_type = get_bits(gb, 6); + *nal_type = (uint8_t)get_bits(gb, 6); get_bits(gb, 9); } @@ -297,17 +297,17 @@ static void hvcc_parse_ptl(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord uint8_t sub_layer_profile_present_flag[7]; // max sublayers uint8_t sub_layer_level_present_flag[7]; // max sublayers - general_ptl.profile_space = get_bits(gb, 2); - general_ptl.tier_flag = get_bits(gb, 1); - general_ptl.profile_idc = get_bits(gb, 5); + general_ptl.profile_space = (uint8_t)get_bits(gb, 2); + general_ptl.tier_flag = (uint8_t)get_bits(gb, 1); + general_ptl.profile_idc = (uint8_t)get_bits(gb, 5); general_ptl.profile_compatibility_flags = get_bits_long(gb, 32); general_ptl.constraint_indicator_flags = get_bits64(gb, 48); - general_ptl.level_idc = get_bits(gb, 8); + general_ptl.level_idc = (uint8_t)get_bits(gb, 8); hvcc_update_ptl(hvcc, &general_ptl); for (i = 0; i < max_sub_layers_minus1; i++) { - sub_layer_profile_present_flag[i] = get_bits(gb, 1); - sub_layer_level_present_flag[i] = get_bits(gb, 1); + sub_layer_profile_present_flag[i] = (uint8_t)get_bits(gb, 1); + sub_layer_level_present_flag[i] = (uint8_t)get_bits(gb, 1); } // skip the rest @@ -332,7 +332,7 @@ static int hvcc_parse_vps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord unsigned int vps_max_sub_layers_minus1; skip_bits(gb, 12); vps_max_sub_layers_minus1 = get_bits(gb, 3); - hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, vps_max_sub_layers_minus1 + 1); + hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, (uint8_t)(vps_max_sub_layers_minus1 + 1)); skip_bits(gb, 17); hvcc_parse_ptl(gb, hvcc, vps_max_sub_layers_minus1); return 0; @@ -377,9 +377,9 @@ static int parse_rps(HevcGetBitContext *gb, unsigned int rps_idx, unsigned int n for (i = 0; i <= num_delta_pocs[rps_idx - 1]; i++) { uint8_t use_delta_flag = 0; - uint8_t used_by_curr_pic_flag = get_bits(gb, 1); + uint8_t used_by_curr_pic_flag = (uint8_t)get_bits(gb, 1); if (!used_by_curr_pic_flag) - use_delta_flag = get_bits(gb, 1); + use_delta_flag = (uint8_t)get_bits(gb, 1); if (used_by_curr_pic_flag || use_delta_flag) num_delta_pocs[rps_idx]++; @@ -433,11 +433,11 @@ static int skip_hrd_parameters(HevcGetBitContext *gb, uint8_t cprms_present_flag uint8_t vcl_hrd_parameters_present_flag = 0; if (cprms_present_flag) { - nal_hrd_parameters_present_flag = get_bits(gb, 1); - vcl_hrd_parameters_present_flag = get_bits(gb, 1); + nal_hrd_parameters_present_flag = (uint8_t)get_bits(gb, 1); + vcl_hrd_parameters_present_flag = (uint8_t)get_bits(gb, 1); if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) { - sub_pic_hrd_params_present_flag = get_bits(gb, 1); + sub_pic_hrd_params_present_flag = (uint8_t)get_bits(gb, 1); if (sub_pic_hrd_params_present_flag) get_bits(gb, 19); @@ -454,15 +454,15 @@ static int skip_hrd_parameters(HevcGetBitContext *gb, uint8_t cprms_present_flag unsigned int cpb_cnt_minus1 = 0; uint8_t low_delay_hrd_flag = 0; uint8_t fixed_pic_rate_within_cvs_flag = 0; - uint8_t fixed_pic_rate_general_flag = get_bits(gb, 1); + uint8_t fixed_pic_rate_general_flag = (uint8_t)get_bits(gb, 1); if (!fixed_pic_rate_general_flag) - fixed_pic_rate_within_cvs_flag = get_bits(gb, 1); + fixed_pic_rate_within_cvs_flag = (uint8_t)get_bits(gb, 1); if (fixed_pic_rate_within_cvs_flag) get_ue_golomb_long(gb); else - low_delay_hrd_flag = get_bits(gb, 1); + low_delay_hrd_flag = (uint8_t)get_bits(gb, 1); if (!low_delay_hrd_flag) { cpb_cnt_minus1 = get_ue_golomb_long(gb); @@ -532,7 +532,7 @@ static void hvcc_parse_vui(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord min_spatial_segmentation_idc = get_ue_golomb_long(gb); hvcc->min_spatial_segmentation_idc = - min_u16(hvcc->min_spatial_segmentation_idc, min_spatial_segmentation_idc); + min_u16(hvcc->min_spatial_segmentation_idc, (uint16_t)min_spatial_segmentation_idc); get_ue_golomb_long(gb); // max_bytes_per_pic_denom get_ue_golomb_long(gb); // max_bits_per_min_cu_denom @@ -549,15 +549,15 @@ static int hvcc_parse_sps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_bits(gb, 4); // sps_video_parameter_set_id sps_max_sub_layers_minus1 = get_bits(gb, 3); - hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, sps_max_sub_layers_minus1 + 1); + hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, (uint8_t)(sps_max_sub_layers_minus1 + 1)); - hvcc->temporalIdNested = get_bits(gb, 1); + hvcc->temporalIdNested = (uint8_t)get_bits(gb, 1); hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1); get_ue_golomb_long(gb); // sps_seq_parameter_set_id - hvcc->chromaFormat = get_ue_golomb_long(gb); + hvcc->chromaFormat = (uint8_t)get_ue_golomb_long(gb); if (hvcc->chromaFormat == 3) get_bits(gb, 1); // separate_colour_plane_flag @@ -572,8 +572,8 @@ static int hvcc_parse_sps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_ue_golomb_long(gb); // conf_win_bottom_offset } - hvcc->bitDepthLumaMinus8 = get_ue_golomb_long(gb); - hvcc->bitDepthChromaMinus8 = get_ue_golomb_long(gb); + hvcc->bitDepthLumaMinus8 = (uint8_t)get_ue_golomb_long(gb); + hvcc->bitDepthChromaMinus8 = (uint8_t)get_ue_golomb_long(gb); log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(gb); /* sps_sub_layer_ordering_info_present_flag */ @@ -660,8 +660,8 @@ static int hvcc_parse_pps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_bits(gb, 4); - tiles_enabled_flag = get_bits(gb, 1); - entropy_coding_sync_enabled_flag = get_bits(gb, 1); + tiles_enabled_flag = (uint8_t)get_bits(gb, 1); + entropy_coding_sync_enabled_flag = (uint8_t)get_bits(gb, 1); if (entropy_coding_sync_enabled_flag && tiles_enabled_flag) hvcc->parallelismType = 0; // mixed-type parallel decoding diff --git a/shared/bpm/bpm.c.h b/shared/bpm/bpm.c.h index c2b6f786ed..bac2192dea 100644 --- a/shared/bpm/bpm.c.h +++ b/shared/bpm/bpm.c.h @@ -324,7 +324,7 @@ static bool process_metrics(obs_output_t *output, struct encoder_packet *out, st struct encoder_packet backup = *out; sei_t sei; uint8_t *data = NULL; - size_t size; + size_t size = 0; long ref = 1; bool avc = false; bool hevc = false; diff --git a/shared/ipc-util/ipc-util/pipe-windows.c.h b/shared/ipc-util/ipc-util/pipe-windows.c.h index 285569cb78..58893e3c3b 100644 --- a/shared/ipc-util/ipc-util/pipe-windows.c.h +++ b/shared/ipc-util/ipc-util/pipe-windows.c.h @@ -131,8 +131,8 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param) break; } - DWORD wait = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); - if (wait != WAIT_OBJECT_0) { + DWORD wait_result = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); + if (wait_result != WAIT_OBJECT_0) { break; } diff --git a/shared/media-playback/media-playback/cache.c.h b/shared/media-playback/media-playback/cache.c.h index 18da3e2f49..c7d0d80d04 100644 --- a/shared/media-playback/media-playback/cache.c.h +++ b/shared/media-playback/media-playback/cache.c.h @@ -168,7 +168,7 @@ static void seek_to(mp_cache_t *c, int64_t pos) int64_t pos_ns = c->speed > 0 ? pos * 1000 * 100 / c->speed : pos * 1000; if (c->has_video) { - struct obs_source_frame *v; + struct obs_source_frame *v = NULL; for (size_t i = 0; i < c->video_frames.num; i++) { v = &c->video_frames.array[i]; @@ -187,7 +187,7 @@ static void seek_to(mp_cache_t *c, int64_t pos) } } if (c->has_audio) { - struct obs_source_audio *a; + struct obs_source_audio *a = NULL; for (size_t i = 0; i < c->audio_segments.num; i++) { a = &c->audio_segments.array[i]; new_a_idx = i; diff --git a/shared/media-playback/media-playback/decode.c.h b/shared/media-playback/media-playback/decode.c.h index ea82de2436..72996b5f94 100644 --- a/shared/media-playback/media-playback/decode.c.h +++ b/shared/media-playback/media-playback/decode.c.h @@ -138,7 +138,7 @@ static uint16_t get_max_luminance(const AVStream *stream) } } - return max_luminance; + return (uint16_t)max_luminance; } bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw) diff --git a/shared/media-playback/media-playback/media.c.h b/shared/media-playback/media-playback/media.c.h index 02a3f89b89..ea31ffba9e 100644 --- a/shared/media-playback/media-playback/media.c.h +++ b/shared/media-playback/media-playback/media.c.h @@ -416,7 +416,7 @@ void mp_media_next_audio(mp_media_t *m) audio.data[i] = f->data[i]; audio.samples_per_sec = f->sample_rate * m->speed / 100; - audio.speakers = convert_speaker_layout(f->ch_layout.nb_channels); + audio.speakers = convert_speaker_layout((uint8_t)f->ch_layout.nb_channels); audio.format = convert_sample_format(f->format); audio.frames = f->nb_samples; audio.timestamp = m->full_decode ? d->frame_pts From 320b618cde9d09d3dba3618a53468475798dec04 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 19:02:18 -0700 Subject: [PATCH 19/63] build(msvc): clear the wave 4 /W4 findings in obs-outputs and the tests Windows Tier 2 on a92e9af reached the obs-outputs TUs and reported four classes. The two first-party ones are fixed at the site by initializing the locals MSVC cannot prove are written: mp4-mux's parsed_packet (no parse arm matches an unknown video codec) and rtmp-av1's seq_params (written in the OB1 sequence-header case that the !nb_seq guard makes mandatory). The other two are the test executables' own build: C4201 arrives through C++ TUs (test executables compile frontend *.cpp against libobs headers, where the nameless structs in vec{2,3,4}.h and profiler.h are a nonstandard C++ extension), and C4206/C4706 are the vendored librtmp sources those tests compile. Both join the existing MSVC block in test/cmocka/CMakeLists.txt, which is the /W4 analogue of the clang -Wno-* list that file already carries (existing C tests are not edited for a new warning, #516). Refs #2626 --- plugins/obs-outputs/mp4-mux.c.h | 5 ++++- plugins/obs-outputs/rtmp-av1.c.h | 5 ++++- test/cmocka/CMakeLists.txt | 12 ++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/obs-outputs/mp4-mux.c.h b/plugins/obs-outputs/mp4-mux.c.h index 74d0400b8b..3590d1be7c 100644 --- a/plugins/obs-outputs/mp4-mux.c.h +++ b/plugins/obs-outputs/mp4-mux.c.h @@ -2908,7 +2908,10 @@ void mp4_mux_destroy(struct mp4_mux *mux) bool mp4_mux_submit_packet(struct mp4_mux *mux, struct encoder_packet *pkt) { struct mp4_track *track = NULL; - struct encoder_packet parsed_packet; + /* Every branch below fills this except one: a video packet whose track + * codec matches no parse arm. Zero-init keeps that path well defined + * (MSVC reports C4701 at /W4 because it cannot prove a branch ran). */ + struct encoder_packet parsed_packet = {0}; enum obs_encoder_type type = pkt->type; bool fragment_ready = mux->next_frag_pts > 0; diff --git a/plugins/obs-outputs/rtmp-av1.c.h b/plugins/obs-outputs/rtmp-av1.c.h index 419533f4cf..3f2dd9c03c 100644 --- a/plugins/obs-outputs/rtmp-av1.c.h +++ b/plugins/obs-outputs/rtmp-av1.c.h @@ -449,7 +449,10 @@ size_t obs_parse_av1_header(uint8_t **header, const uint8_t *data, size_t size) } // AV1S init - AV1SequenceParameters seq_params; + /* Filled by parse_sequence_header() in the AV1_OBU_SEQUENCE_HEADER case, + * which the !nb_seq guard below makes mandatory; MSVC cannot see that + * through the switch and reports C4701 at /W4. */ + AV1SequenceParameters seq_params = {0}; int nb_seq = 0, seq_size = 0, meta_size = 0; const uint8_t *seq = 0, *meta = 0; diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index d7df883104..5a0223d5aa 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -81,16 +81,28 @@ add_compile_options($<$:-Wno-comma>) # C4456/C4459 a test helper or local shadowing an outer local/global # C4702 the non-returning uthash_fatal path at the end of every HASH_* block # (the reason libobs-objects carries /wd4702 as well) +# C4206/C4706 the vendored librtmp classes (empty unity TU, assignment used as +# a condition); these tests compile librtmp into their own executable, +# the same reason C4244/C4245 are listed. The product target's own +# handling is a separate decision: the Visual Studio generator ignores +# its per-source COMPILE_OPTIONS. add_compile_options( $<$:/wd4132> $<$:/wd4201> + $<$:/wd4206> $<$:/wd4244> $<$:/wd4245> $<$:/wd4310> $<$:/wd4456> $<$:/wd4459> $<$:/wd4702> + $<$:/wd4706> ) +# C4201 reaches the tests through C++ TUs too: several test executables compile +# frontend *.cpp sources against the libobs headers, and the nameless structs in +# libobs/graphics/vec{2,3,4}.h and libobs/util/profiler.h are a nonstandard C++ +# extension (C11 6.7.2.1p13 is what makes them legal C). +add_compile_options($<$:/wd4201>) # Per-test sanitizers (obs-rust/obs-studio#159). Some tests compile the code # they check with ASan/UBSan so a bug fails the test. Those flags are added From 885f56ab495b129593313ef8a8abeb45112e1080 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 19:32:09 -0700 Subject: [PATCH 20/63] build(msvc): fix the wave 5 /W4 findings in libobs-opengl and libobs-d3d11 Windows Tier 2 on 243a50f reached the renderer targets and reported three classes, all first-party: - C4100: gl-windows' init_default_swap never used its gs_device_t and device_is_monitor_hdr used neither argument. Both now call UNUSED_PARAMETER(), which is exactly what the gl-nix sibling does for the same two functions. - C4245: sp_getsampler's not-found sentinel was a plain -1 returned as size_t. Return (size_t)-1, the value its only caller already compares against. - C4458: thirteen locals/parameters in the d3d11 backend shadowed class members (data/format/srd/numVerts/adapter). Renamed to plane_data, tex_format, subresource_data, num_verts and dxgi_adapter; no behaviour change, and the this->member = local lines stay explicit. Refs #2626 --- libobs-d3d11/d3d11-rebuild.cpp.hpp | 16 +++++------ libobs-d3d11/d3d11-subsystem.cpp.hpp | 6 ++-- libobs-d3d11/d3d11-texture2d.cpp.hpp | 38 ++++++++++++------------- libobs-d3d11/d3d11-texture3d.cpp.hpp | 28 +++++++++--------- libobs-d3d11/d3d11-vertexbuffer.cpp.hpp | 4 +-- libobs-opengl/gl-shaderparser.c.h | 2 +- libobs-opengl/gl-windows.c.h | 5 ++++ 7 files changed, 52 insertions(+), 47 deletions(-) diff --git a/libobs-d3d11/d3d11-rebuild.cpp.hpp b/libobs-d3d11/d3d11-rebuild.cpp.hpp index 5d5de32d77..0a886d88e8 100644 --- a/libobs-d3d11/d3d11-rebuild.cpp.hpp +++ b/libobs-d3d11/d3d11-rebuild.cpp.hpp @@ -34,10 +34,10 @@ void gs_index_buffer::Rebuild(ID3D11Device *dev) void gs_texture_2d::RebuildSharedTextureFallback() { - static const gs_color_format format = GS_BGRA; - static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(format); - static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(format); - static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(format); + static const gs_color_format tex_format = GS_BGRA; + static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(tex_format); + static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(tex_format); + static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(tex_format); td = {}; td.Width = 2; @@ -308,10 +308,10 @@ void gs_timer_range::Rebuild(ID3D11Device *dev) void gs_texture_3d::RebuildSharedTextureFallback() { - static const gs_color_format format = GS_BGRA; - static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(format); - static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(format); - static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(format); + static const gs_color_format tex_format = GS_BGRA; + static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(tex_format); + static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(tex_format); + static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(tex_format); td = {}; td.Width = 2; diff --git a/libobs-d3d11/d3d11-subsystem.cpp.hpp b/libobs-d3d11/d3d11-subsystem.cpp.hpp index baa03eee8e..5a35ffabad 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp.hpp +++ b/libobs-d3d11/d3d11-subsystem.cpp.hpp @@ -1188,11 +1188,11 @@ gs_monitor_color_info gs_device::GetMonitorColorInfo(HMONITOR hMonitor) } } - ComPtr adapter; + ComPtr dxgi_adapter; ComPtr output; ComPtr output6; - for (UINT adapterIndex = 0; SUCCEEDED(factory1->EnumAdapters(adapterIndex, &adapter)); ++adapterIndex) { - for (UINT outputIndex = 0; SUCCEEDED(adapter->EnumOutputs(outputIndex, &output)); ++outputIndex) { + for (UINT adapterIndex = 0; SUCCEEDED(factory1->EnumAdapters(adapterIndex, &dxgi_adapter)); ++adapterIndex) { + for (UINT outputIndex = 0; SUCCEEDED(dxgi_adapter->EnumOutputs(outputIndex, &output)); ++outputIndex) { DXGI_OUTPUT_DESC1 desc1; if (SUCCEEDED(output->QueryInterface(&output6)) && SUCCEEDED(output6->GetDesc1(&desc1)) && (desc1.Monitor == hMonitor)) { diff --git a/libobs-d3d11/d3d11-texture2d.cpp.hpp b/libobs-d3d11/d3d11-texture2d.cpp.hpp index 522928dd2c..def26abc69 100644 --- a/libobs-d3d11/d3d11-texture2d.cpp.hpp +++ b/libobs-d3d11/d3d11-texture2d.cpp.hpp @@ -17,7 +17,7 @@ #include "libobs-d3d11/build/d3d11.pch.hpp" -void gs_texture_2d::InitSRD(std::vector &srd) +void gs_texture_2d::InitSRD(std::vector &subresource_data) { uint32_t rowSizeBytes = width * gs_get_format_bpp(format); uint32_t texSizeBytes = height * rowSizeBytes / 8; @@ -40,7 +40,7 @@ void gs_texture_2d::InitSRD(std::vector &srd) newSRD.pSysMem = data[curTex++].data(); newSRD.SysMemPitch = newRowSize; newSRD.SysMemSlicePitch = newTexSize; - srd.push_back(newSRD); + subresource_data.push_back(newSRD); newRowSize /= 2; newTexSize /= 4; @@ -48,7 +48,7 @@ void gs_texture_2d::InitSRD(std::vector &srd) } } -void gs_texture_2d::BackupTexture(const uint8_t *const *data) +void gs_texture_2d::BackupTexture(const uint8_t *const *plane_data) { uint32_t textures = type == GS_TEXTURE_CUBE ? 6 : 1; uint32_t bbp = gs_get_format_bpp(format); @@ -61,7 +61,7 @@ void gs_texture_2d::BackupTexture(const uint8_t *const *data) for (uint32_t lv = 0; lv < levels; lv++) { uint32_t i = levels * t + lv; - if (!data[i]) { + if (!plane_data[i]) { break; } @@ -69,7 +69,7 @@ void gs_texture_2d::BackupTexture(const uint8_t *const *data) std::vector &subData = this->data[i]; subData.resize(texSize); - memcpy(&subData[0], data[i], texSize); + memcpy(&subData[0], plane_data[i], texSize); if (w > 1) { w /= 2; @@ -97,7 +97,7 @@ void gs_texture_2d::GetSharedHandle(IDXGIResource *dxgi_res) } } -void gs_texture_2d::InitTexture(const uint8_t *const *data) +void gs_texture_2d::InitTexture(const uint8_t *const *plane_data) { HRESULT hr; @@ -130,12 +130,12 @@ void gs_texture_2d::InitTexture(const uint8_t *const *data) td.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; } - if (data) { - BackupTexture(data); + if (plane_data) { + BackupTexture(plane_data); InitSRD(srd); } - hr = device->device->CreateTexture2D(&td, data ? srd.data() : NULL, texture.Assign()); + hr = device->device->CreateTexture2D(&td, plane_data ? srd.data() : NULL, texture.Assign()); if (FAILED(hr)) { throw HRError("Failed to create 2D texture", hr); } @@ -340,18 +340,18 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t handle, bool ntHandle texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_2D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } @@ -363,18 +363,18 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, ID3D11Texture2D *obj) texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_2D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } diff --git a/libobs-d3d11/d3d11-texture3d.cpp.hpp b/libobs-d3d11/d3d11-texture3d.cpp.hpp index 21cc20cca8..ab0f1c9f23 100644 --- a/libobs-d3d11/d3d11-texture3d.cpp.hpp +++ b/libobs-d3d11/d3d11-texture3d.cpp.hpp @@ -17,7 +17,7 @@ #include "libobs-d3d11/build/d3d11.pch.hpp" -void gs_texture_3d::InitSRD(std::vector &srd) +void gs_texture_3d::InitSRD(std::vector &subresource_data) { uint32_t rowSizeBits = width * gs_get_format_bpp(format); uint32_t sliceSizeBytes = height * rowSizeBits / 8; @@ -35,14 +35,14 @@ void gs_texture_3d::InitSRD(std::vector &srd) newSRD.pSysMem = data[level].data(); newSRD.SysMemPitch = newRowSize; newSRD.SysMemSlicePitch = newSlizeSize; - srd.push_back(newSRD); + subresource_data.push_back(newSRD); newRowSize /= 2; newSlizeSize /= 4; } } -void gs_texture_3d::BackupTexture(const uint8_t *const *data) +void gs_texture_3d::BackupTexture(const uint8_t *const *plane_data) { this->data.resize(levels); @@ -52,7 +52,7 @@ void gs_texture_3d::BackupTexture(const uint8_t *const *data) const uint32_t bbp = gs_get_format_bpp(format); for (uint32_t i = 0; i < levels; i++) { - if (!data[i]) { + if (!plane_data[i]) { break; } @@ -60,7 +60,7 @@ void gs_texture_3d::BackupTexture(const uint8_t *const *data) this->data[i].resize(texSize); std::vector &subData = this->data[i]; - memcpy(&subData[0], data[i], texSize); + memcpy(&subData[0], plane_data[i], texSize); if (w > 1) { w /= 2; @@ -90,7 +90,7 @@ void gs_texture_3d::GetSharedHandle(IDXGIResource *dxgi_res) } } -void gs_texture_3d::InitTexture(const uint8_t *const *data) +void gs_texture_3d::InitTexture(const uint8_t *const *plane_data) { HRESULT hr; @@ -114,12 +114,12 @@ void gs_texture_3d::InitTexture(const uint8_t *const *data) td.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; } - if (data) { - BackupTexture(data); + if (plane_data) { + BackupTexture(plane_data); InitSRD(srd); } - hr = device->device->CreateTexture3D(&td, data ? srd.data() : NULL, texture.Assign()); + hr = device->device->CreateTexture3D(&td, plane_data ? srd.data() : NULL, texture.Assign()); if (FAILED(hr)) { throw HRError("Failed to create 3D texture", hr); } @@ -217,19 +217,19 @@ gs_texture_3d::gs_texture_3d(gs_device_t *device, uint32_t handle) texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_3D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; this->depth = td.Depth; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } diff --git a/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp b/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp index 02ccb83d3e..5628633ad9 100644 --- a/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp +++ b/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp @@ -73,7 +73,7 @@ UINT gs_vertex_buffer::MakeBufferList(gs_vertex_shader *shader, ID3D11Buffer **b return numBuffers; } -void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t numVerts, void *array, ID3D11Buffer **buffer) +void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t num_verts, void *array, ID3D11Buffer **buffer) { D3D11_BUFFER_DESC bd; D3D11_SUBRESOURCE_DATA srd; @@ -85,7 +85,7 @@ void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t numVert bd.Usage = dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT; bd.CPUAccessFlags = dynamic ? D3D11_CPU_ACCESS_WRITE : 0; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bd.ByteWidth = UINT(elementSize * numVerts); + bd.ByteWidth = UINT(elementSize * num_verts); srd.pSysMem = array; hr = device->device->CreateBuffer(&bd, &srd, buffer); diff --git a/libobs-opengl/gl-shaderparser.c.h b/libobs-opengl/gl-shaderparser.c.h index 5e27ae53ad..2870629255 100644 --- a/libobs-opengl/gl-shaderparser.c.h +++ b/libobs-opengl/gl-shaderparser.c.h @@ -40,7 +40,7 @@ static inline size_t sp_getsampler(struct gl_shader_parser *glsp, struct cf_toke return i; } - return -1; + return (size_t)-1; } static inline int cmp_type(const char *name, const size_t name_len, const char *type, const size_t type_len) diff --git a/libobs-opengl/gl-windows.c.h b/libobs-opengl/gl-windows.c.h index f3d30ae3a9..1e1f9ab98d 100644 --- a/libobs-opengl/gl-windows.c.h +++ b/libobs-opengl/gl-windows.c.h @@ -384,6 +384,8 @@ static bool create_dummy_window(struct gl_platform *plat) static bool init_default_swap(struct gl_platform *plat, gs_device_t *device, int pixel_format, PIXELFORMATDESCRIPTOR *pfd) { + UNUSED_PARAMETER(device); + if (!gl_setpixelformat(plat->window.hdc, pixel_format, pfd)) return false; @@ -586,6 +588,9 @@ extern void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width, EXPORT bool device_is_monitor_hdr(gs_device_t *device, void *monitor) { + UNUSED_PARAMETER(device); + UNUSED_PARAMETER(monitor); + return false; } From 35c6deb58c0fb793f5b98f55fc25a5ba63af27eb Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:26:30 -0700 Subject: [PATCH 21/63] fix(msvc): fix the /W4 findings the Windows app lane reports in the plugins (#2626) PR CI builds no app, so the /W4 findings in the plugin and frontend C/C++ TUs only appear in a release-lane run. This is that wave, all fixed at the site: - shadowed locals/parameters renamed (C4456/C4457/C4458/C4459) in decklink, decklink-captions, decklink-output-ui, frontend-tools, obs-qsv11, obs-text, shared/properties-view, win-wasapi and text-freetype2 - unreferenced parameters silenced with UNUSED_PARAMETER (C4100) in captions-mssapi-stream, nv-filters, obs-nvenc and obs-outputs/net-if-host-windows - dead locals that exist only for their side effect keep the call and cast the result to void (C4189, nv-filters sliders and parent_flags) - explicit narrowing casts where the value is already bounded (C4244/C4245) in obs-ffmpeg-srt, obs-qsv11, obs-qsv11.c.h and decklink's video_trc assignment - remove the unreachable duplicate return after convert_ffmpeg_sample_format's switch default (C4702, obs-ffmpeg-formats.h) Refs #2626. --- .../decklink-captions.cpp.hpp | 7 +- .../DecklinkOutputUI.cpp.hpp | 12 +- plugins/decklink/DecklinkOutput.cpp.hpp | 6 +- plugins/decklink/OBSVideoFrame.cpp.hpp | 4 +- .../decklink/decklink-device-instance.cpp.hpp | 6 +- plugins/decklink/decklink-output.cpp.hpp | 8 +- plugins/decklink/decklink-source.cpp.hpp | 4 +- .../captions-mssapi-stream.cpp.hpp | 19 ++- plugins/frontend-tools/captions.cpp.hpp | 13 +- plugins/nv-filters/nvidia-audiofx-filter.c.h | 13 +- plugins/nv-filters/nvidia-videofx-filter.c.h | 5 + plugins/obs-ffmpeg/obs-ffmpeg-formats.h | 3 - plugins/obs-ffmpeg/obs-ffmpeg-srt.h | 8 +- plugins/obs-nvenc/nvenc-d3d11.c.h | 2 + plugins/obs-outputs/net-if-host-windows.c.h | 2 + .../obs-qsv11/QSV_Encoder_Internal.cpp.hpp | 12 +- .../obs-qsv11/common_utils_windows.cpp.hpp | 11 +- plugins/obs-qsv11/obs-qsv11.c.h | 10 +- plugins/obs-text/gdiplus/obs-text.cpp.hpp | 12 +- plugins/text-freetype2/find-font.c.h | 4 +- plugins/win-wasapi/win-wasapi.cpp.hpp | 86 +++++------ .../properties-view/properties-view.cpp.hpp | 137 +++++++++--------- 22 files changed, 204 insertions(+), 180 deletions(-) diff --git a/plugins/decklink-captions/decklink-captions.cpp.hpp b/plugins/decklink-captions/decklink-captions.cpp.hpp index 233b4014c4..7c9ab8930d 100644 --- a/plugins/decklink-captions/decklink-captions.cpp.hpp +++ b/plugins/decklink-captions/decklink-captions.cpp.hpp @@ -46,7 +46,8 @@ DecklinkCaptionsUI::DecklinkCaptionsUI(QWidget *parent) : QDialog(parent), ui(ne ui->source->blockSignals(true); ui->source->addItem(QStringLiteral("")); ui->source->setCurrentIndex(0); - obs_enum_sources([](void *data, obs_source_t *source) { return (*static_cast(data))(source); }, &cb); + obs_enum_sources([](void *cbData, obs_source_t *source) { return (*static_cast(cbData))(source); }, + &cb); ui->source->blockSignals(false); } @@ -60,12 +61,12 @@ void DecklinkCaptionsUI::on_source_currentIndexChanged(int) captions->start(); } -static void caption_callback(void * /* param */, obs_source_t * /* source */, const struct obs_source_cea_708 *captions) +static void caption_callback(void * /* param */, obs_source_t * /* source */, const struct obs_source_cea_708 *cea708) { obs_output *output = obs_frontend_get_streaming_output(); if (output) { if (obs_frontend_streaming_active() && obs_output_active(output)) { - obs_output_caption(output, captions); + obs_output_caption(output, cea708); } obs_output_release(output); } diff --git a/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp b/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp index 65905cd439..b807697d91 100644 --- a/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp +++ b/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp @@ -28,9 +28,9 @@ void DecklinkOutputUI::SetupPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(); - if (data) { - obs_data_apply(settings, data); + OBSData settingsData = load_settings(); + if (settingsData) { + obs_data_apply(settings, settingsData); } propertiesView = new OBSPropertiesView(settings, "decklink_output", @@ -64,9 +64,9 @@ void DecklinkOutputUI::SetupPreviewPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_preview_settings(); - if (data) { - obs_data_apply(settings, data); + OBSData previewSettingsData = load_preview_settings(); + if (previewSettingsData) { + obs_data_apply(settings, previewSettingsData); } previewPropertiesView = new OBSPropertiesView(settings, "decklink_output", diff --git a/plugins/decklink/DecklinkOutput.cpp.hpp b/plugins/decklink/DecklinkOutput.cpp.hpp index 2be7e9dd60..8b90f81f53 100644 --- a/plugins/decklink/DecklinkOutput.cpp.hpp +++ b/plugins/decklink/DecklinkOutput.cpp.hpp @@ -94,10 +94,10 @@ void DeckLinkOutput::WriteAudio(audio_data *frames) instance->WriteAudio(frames); } -void DeckLinkOutput::SetSize(int width, int height) +void DeckLinkOutput::SetSize(int newWidth, int newHeight) { - this->width = width; - this->height = height; + this->width = newWidth; + this->height = newHeight; } int DeckLinkOutput::GetWidth() diff --git a/plugins/decklink/OBSVideoFrame.cpp.hpp b/plugins/decklink/OBSVideoFrame.cpp.hpp index 2d42b47bdd..02dee3178c 100644 --- a/plugins/decklink/OBSVideoFrame.cpp.hpp +++ b/plugins/decklink/OBSVideoFrame.cpp.hpp @@ -30,14 +30,14 @@ HRESULT OBSVideoFrame::SetTimecode(BMDTimecodeFormat format, IDeckLinkTimecode * HRESULT OBSVideoFrame::SetTimecodeFromComponents(BMDTimecodeFormat format, uint8_t hours, uint8_t minutes, uint8_t seconds, - uint8_t frames, BMDTimecodeFlags flags) + uint8_t frames, BMDTimecodeFlags timecodeFlags) { UNUSED_PARAMETER(format); UNUSED_PARAMETER(hours); UNUSED_PARAMETER(minutes); UNUSED_PARAMETER(seconds); UNUSED_PARAMETER(frames); - UNUSED_PARAMETER(flags); + UNUSED_PARAMETER(timecodeFlags); return 0; } diff --git a/plugins/decklink/decklink-device-instance.cpp.hpp b/plugins/decklink/decklink-device-instance.cpp.hpp index cbf2ff10a1..9ed9b5b4d6 100644 --- a/plugins/decklink/decklink-device-instance.cpp.hpp +++ b/plugins/decklink/decklink-device-instance.cpp.hpp @@ -227,7 +227,7 @@ void DeckLinkDeviceInstance::HandleVideoFrame(IDeckLinkVideoInputFrame *videoFra } } } - currentFrame.trc = trc; + currentFrame.trc = static_cast(trc); obs_source_output_video2(static_cast(decklink)->GetSource(), ¤tFrame); } @@ -580,12 +580,12 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_) /* No conversion when create didn't find the device or mode: not HDR (#2144). */ const struct video_scale_info *conversion = obs_output_get_video_conversion(decklinkOutput->GetOutput()); const bool enable_hdr = source_hdr && conversion && conversion->colorspace == VIDEO_CS_2100_PQ; - BMDPixelFormat pixelFormat = enable_hdr ? bmdFormat10BitRGBXLE : bmdFormat8BitBGRA; + const BMDPixelFormat outputPixelFormat = enable_hdr ? bmdFormat10BitRGBXLE : bmdFormat8BitBGRA; const int64_t minimumPrerollFrames = std::max(device->GetMinimumPrerollFrames(), INT64_C(3)); for (int64_t i = 0; i < minimumPrerollFrames; ++i) { ComPtr decklinkOutputFrame; HRESULT result = output_->CreateVideoFrame(decklinkOutput->GetWidth(), decklinkOutput->GetHeight(), - rowSize, pixelFormat, bmdFrameFlagDefault, + rowSize, outputPixelFormat, bmdFrameFlagDefault, &decklinkOutputFrame); if (result != S_OK) { blog(LOG_ERROR, "failed to create video frame 0x%X", result); diff --git a/plugins/decklink/decklink-output.cpp.hpp b/plugins/decklink/decklink-output.cpp.hpp index 7973392c3e..cf91ca7dd2 100644 --- a/plugins/decklink/decklink-output.cpp.hpp +++ b/plugins/decklink/decklink-output.cpp.hpp @@ -222,10 +222,10 @@ static bool decklink_output_device_changed(obs_properties_t *props, obs_property struct obs_video_info ovi; if (obs_get_video_info(&ovi)) { - for (DeckLinkDeviceMode *mode : modes) { - if (mode->IsEqualFrameRate(ovi.fps_num, ovi.fps_den)) { - obs_property_list_add_int(modeList, mode->GetName().c_str(), - mode->GetId()); + for (DeckLinkDeviceMode *deviceMode : modes) { + if (deviceMode->IsEqualFrameRate(ovi.fps_num, ovi.fps_den)) { + obs_property_list_add_int(modeList, deviceMode->GetName().c_str(), + deviceMode->GetId()); } } } diff --git a/plugins/decklink/decklink-source.cpp.hpp b/plugins/decklink/decklink-source.cpp.hpp index 0666356715..dde2b868de 100644 --- a/plugins/decklink/decklink-source.cpp.hpp +++ b/plugins/decklink/decklink-source.cpp.hpp @@ -171,8 +171,8 @@ static bool decklink_device_changed(obs_properties_t *props, obs_property_t *lis const std::vector &modes = device->GetInputModes(); - for (DeckLinkDeviceMode *mode : modes) { - obs_property_list_add_int(modeList, mode->GetName().c_str(), mode->GetId()); + for (DeckLinkDeviceMode *deviceMode : modes) { + obs_property_list_add_int(modeList, deviceMode->GetName().c_str(), deviceMode->GetId()); } if (device->GetMaxChannel() >= 8) { diff --git a/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp b/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp index 795fa30d63..3346ee7153 100644 --- a/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp +++ b/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp @@ -138,6 +138,7 @@ STDMETHODIMP CaptionStream::Read(void *data, ULONG bytes, ULONG *read_bytes) STDMETHODIMP CaptionStream::Write(const void *, ULONG bytes, ULONG *) { debugfunc("data, %lu, written_bytes", bytes); + UNUSED_PARAMETER(bytes); return STG_E_INVALIDFUNCTION; } @@ -163,6 +164,7 @@ STDMETHODIMP CaptionStream::Seek(LARGE_INTEGER move, DWORD origin, ULARGE_INTEGE STDMETHODIMP CaptionStream::SetSize(ULARGE_INTEGER new_size) { debugfunc("%llu", new_size); + UNUSED_PARAMETER(new_size); return STG_E_INVALIDFUNCTION; } @@ -201,6 +203,7 @@ STDMETHODIMP CaptionStream::CopyTo(IStream *stream, ULARGE_INTEGER bytes, ULARGE STDMETHODIMP CaptionStream::Commit(DWORD commit_flags) { debugfunc("%lx", commit_flags); + UNUSED_PARAMETER(commit_flags); /* TODO? */ return S_OK; } @@ -214,6 +217,9 @@ STDMETHODIMP CaptionStream::Revert(void) STDMETHODIMP CaptionStream::LockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type) { debugfunc("%llu, %llu, %ld", offset, size, type); + UNUSED_PARAMETER(offset); + UNUSED_PARAMETER(size); + UNUSED_PARAMETER(type); /* TODO? */ return STG_E_INVALIDFUNCTION; } @@ -221,6 +227,9 @@ STDMETHODIMP CaptionStream::LockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER siz STDMETHODIMP CaptionStream::UnlockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type) { debugfunc("%llu, %llu, %ld", offset, size, type); + UNUSED_PARAMETER(offset); + UNUSED_PARAMETER(size); + UNUSED_PARAMETER(type); /* TODO? */ return STG_E_INVALIDFUNCTION; } @@ -347,18 +356,18 @@ STDMETHODIMP CaptionStream::GetBufferInfo(SPAUDIOBUFFERINFO *buf_info_) return S_OK; } -STDMETHODIMP CaptionStream::GetDefaultFormat(GUID *format, WAVEFORMATEX **co_mem_wfex_out) +STDMETHODIMP CaptionStream::GetDefaultFormat(GUID *format_guid, WAVEFORMATEX **co_mem_wfex_out) { debugfunc("format, co_mem_wfex_out"); - if (!format || !co_mem_wfex_out) { + if (!format_guid || !co_mem_wfex_out) { return E_POINTER; } - void *wfex = CoTaskMemAlloc(sizeof(format)); - memcpy(wfex, &format, sizeof(format)); + void *wfex = CoTaskMemAlloc(sizeof(format_guid)); + memcpy(wfex, &format_guid, sizeof(format_guid)); - *format = SPDFID_WaveFormatEx; + *format_guid = SPDFID_WaveFormatEx; *co_mem_wfex_out = (WAVEFORMATEX *)wfex; return S_OK; } diff --git a/plugins/frontend-tools/captions.cpp.hpp b/plugins/frontend-tools/captions.cpp.hpp index 649e48aaf1..791d2502c5 100644 --- a/plugins/frontend-tools/captions.cpp.hpp +++ b/plugins/frontend-tools/captions.cpp.hpp @@ -71,7 +71,8 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui_Cap ui->source->blockSignals(true); ui->source->addItem(QStringLiteral("")); ui->source->setCurrentIndex(0); - obs_enum_sources([](void *data, obs_source_t *source) { return (*static_cast(data))(source); }, &cb); + obs_enum_sources([](void *cb_data, obs_source_t *source) { return (*static_cast(cb_data))(source); }, + &cb); ui->source->blockSignals(false); for (auto &ht : captions->handler_types) { @@ -96,13 +97,13 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui_Cap bool set_language = false; ui->language->blockSignals(true); - for (int idx = 0; idx < (int)locales.size(); idx++) { - locale_info &locale = locales[idx]; + for (int locale_idx = 0; locale_idx < (int)locales.size(); locale_idx++) { + locale_info &locale = locales[locale_idx]; ui->language->addItem(locale.name->array, (int)locale.id); if (locale.id == captions->lang_id) { - ui->language->setCurrentIndex(idx); + ui->language->setCurrentIndex(locale_idx); set_language = true; } } @@ -239,8 +240,8 @@ void obs_captions::start() captions_handler *h = pair->second.create(caption_text, lang_name); handler.reset(h); - OBSSource s = OBSGetStrongRef(source); - obs_source_add_audio_capture_callback(s, audio_capture, nullptr); + OBSSource capture_source = OBSGetStrongRef(source); + obs_source_add_audio_capture_callback(capture_source, audio_capture, nullptr); } catch (std::string text) { QWidget *window = (QWidget *)obs_frontend_get_main_window(); diff --git a/plugins/nv-filters/nvidia-audiofx-filter.c.h b/plugins/nv-filters/nvidia-audiofx-filter.c.h index a53e43677f..1a7b69b1e0 100644 --- a/plugins/nv-filters/nvidia-audiofx-filter.c.h +++ b/plugins/nv-filters/nvidia-audiofx-filter.c.h @@ -362,13 +362,13 @@ static void *nvidia_audio_initialize(void *data) goto failure; } bool updated_string = ng->sdk_version >= MIN_ARM_AFX_SDK_VERSION; - NvAFX_Status err = NvAFX_GetU32(ng->handle[0], - updated_string ? NVAFX_PARAM_NUM_SAMPLES_PER_INPUT_FRAME - : NVAFX_PARAM_NUM_INPUT_SAMPLES_PER_FRAME, - &ng->num_samples_per_frame); - if (err != NVAFX_STATUS_SUCCESS) { + NvAFX_Status samples_err = NvAFX_GetU32(ng->handle[0], + updated_string ? NVAFX_PARAM_NUM_SAMPLES_PER_INPUT_FRAME + : NVAFX_PARAM_NUM_INPUT_SAMPLES_PER_FRAME, + &ng->num_samples_per_frame); + if (samples_err != NVAFX_STATUS_SUCCESS) { do_log(LOG_ERROR, "NvAFX_GetU32() failed to get the number of samples per frame, error %i", - err); + samples_err); goto failure; } if (ng->num_samples_per_frame != NVAFX_FRAME_SIZE) { @@ -832,6 +832,7 @@ static obs_properties_t *nvidia_audio_properties(void *data) S_METHOD_NVAFX_DEREVERB_DENOISER); obs_property_t *slider = obs_properties_add_float_slider(ppts, S_NVAFX_INTENSITY, TEXT_NVAFX_INTENSITY, 0.0f, 1.0f, 0.01f); + UNUSED_PARAMETER(slider); obs_properties_add_bool(ppts, S_NVAFX_VAD, TEXT_NVAFX_VAD); obs_property_set_modified_callback2(method, nvidia_audio_method_modified, ng); diff --git a/plugins/nv-filters/nvidia-videofx-filter.c.h b/plugins/nv-filters/nvidia-videofx-filter.c.h index 1f531ef515..c1c8f867e3 100644 --- a/plugins/nv-filters/nvidia-videofx-filter.c.h +++ b/plugins/nv-filters/nvidia-videofx-filter.c.h @@ -379,6 +379,8 @@ static void nvvfx_filter_reset(void *data, calldata_t *calldata) struct nvvfx_data *filter = (struct nvvfx_data *)data; NvCV_Status vfxErr; + UNUSED_PARAMETER(calldata); + os_atomic_set_bool(&filter->processing_stop, true); // [A] first destroy if (filter->handle) { @@ -870,6 +872,7 @@ static void nvvfx_filter_render(void *data, gs_effect_t *effect, bool has_blur) const uint32_t target_flags = obs_source_get_output_flags(target); const uint32_t parent_flags = obs_source_get_output_flags(parent); + UNUSED_PARAMETER(parent_flags); bool custom_draw = (target_flags & OBS_SOURCE_CUSTOM_DRAW) != 0; bool async = (target_flags & OBS_SOURCE_ASYNC) != 0; @@ -1048,6 +1051,7 @@ static obs_properties_t *nvvfx_filter_properties(void *data) if (filter->filter_id != S_FX_AIGS) { obs_property_t *strength = obs_properties_add_float_slider(props, S_STRENGTH, TEXT_MODE_BLUR_STRENGTH, 0, 1, 0.05); + UNUSED_PARAMETER(strength); } else { obs_property_t *mode = obs_properties_add_list(props, S_MODE, TEXT_MODE, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); @@ -1057,6 +1061,7 @@ static obs_properties_t *nvvfx_filter_properties(void *data) obs_property_list_add_int(mode, TEXT_MODE_PERF_CHAIR, S_MODE_PERF_CHAIR); obs_property_t *threshold = obs_properties_add_float_slider(props, S_THRESHOLDFX, TEXT_MODE_THRESHOLD, 0, 1, 0.05); + UNUSED_PARAMETER(threshold); obs_property_t *partial = obs_properties_add_int_slider(props, S_PROCESSING, TEXT_PROCESSING, 1, 4, 1); obs_property_set_long_description(partial, TEXT_PROCESSING_HINT); } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h index 89263d4199..e73183c643 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h @@ -112,7 +112,4 @@ static inline enum audio_format convert_ffmpeg_sample_format(enum AVSampleFormat default: return AUDIO_FORMAT_16BIT; } - - /* shouldn't get here */ - return AUDIO_FORMAT_16BIT; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-srt.h b/plugins/obs-ffmpeg/obs-ffmpeg-srt.h index 74fcaa4d58..ecb9af2793 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-srt.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-srt.h @@ -426,7 +426,10 @@ static int libsrt_set_options_pre(URLContext *h, SRTSOCKET fd) if (s->linger >= 0) { struct linger lin; - lin.l_linger = s->linger; + /* struct linger::l_linger is u_short on Windows; the value is + * only used when l_onoff is set, and the cast keeps the existing + * (already truncating) assignment explicit. */ + lin.l_linger = (u_short)s->linger; lin.l_onoff = lin.l_linger > 0 ? 1 : 0; if (libsrt_setsockopt(h, fd, SRTO_LINGER, "SRTO_LINGER", &lin, sizeof(lin)) < 0) { s->last_error.srt_error_code = srt_getlasterror(NULL); @@ -504,7 +507,8 @@ static int libsrt_setup(URLContext *h, const char *uri) return AVERROR(EIO); } la.sin_family = AF_INET; - la.sin_port = htons(port); + /* port is bounded to [1, 65535] by the check after av_url_split */ + la.sin_port = htons((u_short)port); inet_pton(AF_INET, s->localip, &la.sin_addr.s_addr); } diff --git a/plugins/obs-nvenc/nvenc-d3d11.c.h b/plugins/obs-nvenc/nvenc-d3d11.c.h index 158e8f4af4..7bedc61292 100644 --- a/plugins/obs-nvenc/nvenc-d3d11.c.h +++ b/plugins/obs-nvenc/nvenc-d3d11.c.h @@ -23,6 +23,8 @@ typedef HRESULT(WINAPI *CREATEDXGIFACTORY1PROC)(REFIID, void **); bool d3d11_init(struct nvenc_data *enc, obs_data_t *settings) { + UNUSED_PARAMETER(settings); + HMODULE dxgi = get_lib(enc, "DXGI.dll"); HMODULE d3d11 = get_lib(enc, "D3D11.dll"); CREATEDXGIFACTORY1PROC create_dxgi; diff --git a/plugins/obs-outputs/net-if-host-windows.c.h b/plugins/obs-outputs/net-if-host-windows.c.h index 8e47f4c5d9..3358a847d0 100644 --- a/plugins/obs-outputs/net-if-host-windows.c.h +++ b/plugins/obs-outputs/net-if-host-windows.c.h @@ -20,6 +20,8 @@ void netif_host_addr_to_string(char *dest, struct sockaddr_storage *byte_address bool netif_host_str_to_addr(struct sockaddr_storage *out, int *addr_len, const char *addr, bool ipv6) { + UNUSED_PARAMETER(ipv6); + int ret = WSAStringToAddressA((LPSTR)addr, out->ss_family, NULL, (LPSOCKADDR)out, addr_len); if (ret == SOCKET_ERROR) warn("Could not parse address, error code: %d", GetLastError()); diff --git a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp index b972fcec72..9c1e55ece1 100644 --- a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp +++ b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp @@ -553,8 +553,8 @@ mfxStatus QSV_Encoder_Internal::GetVideoParam(enum qsv_codec codec) opt.Header.BufferId = MFX_EXTBUFF_CODING_OPTION_SPSPPS; opt.Header.BufferSz = sizeof(mfxExtCodingOptionSPSPPS); - std::vector extendedBuffers; - extendedBuffers.reserve(2); + std::vector param_ext_buffers; + param_ext_buffers.reserve(2); opt.SPSBuffer = m_SPSBuffer; opt.PPSBuffer = m_PPSBuffer; @@ -568,13 +568,13 @@ mfxStatus QSV_Encoder_Internal::GetVideoParam(enum qsv_codec codec) opt_vps.VPSBuffer = m_VPSBuffer; opt_vps.VPSBufSize = 1024; - extendedBuffers.push_back((mfxExtBuffer *)&opt_vps); + param_ext_buffers.push_back((mfxExtBuffer *)&opt_vps); } - extendedBuffers.push_back((mfxExtBuffer *)&opt); + param_ext_buffers.push_back((mfxExtBuffer *)&opt); - m_parameter.ExtParam = extendedBuffers.data(); - m_parameter.NumExtParam = (mfxU16)extendedBuffers.size(); + m_parameter.ExtParam = param_ext_buffers.data(); + m_parameter.NumExtParam = (mfxU16)param_ext_buffers.size(); mfxStatus sts = m_pmfxENC->GetVideoParam(&m_parameter); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); diff --git a/plugins/obs-qsv11/common_utils_windows.cpp.hpp b/plugins/obs-qsv11/common_utils_windows.cpp.hpp index 143562a008..e2b25a7c9b 100644 --- a/plugins/obs-qsv11/common_utils_windows.cpp.hpp +++ b/plugins/obs-qsv11/common_utils_windows.cpp.hpp @@ -7,6 +7,7 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession, mfxFrameAllocator *pmfxAllocator, mfxHDL *deviceHandle, bool bCreateSharedHandles, enum qsv_codec codec, void **data) { + UNUSED_PARAMETER(ver); UNUSED_PARAMETER(codec); UNUSED_PARAMETER(data); @@ -147,7 +148,7 @@ static bool enum_luids(void *param, uint32_t idx, uint64_t luid) return true; } -void check_adapters(struct adapter_info *adapters, size_t *adapter_count) +void check_adapters(struct adapter_info *adapter_info_list, size_t *adapter_count_out) { char *test_exe = os_get_executable_path_ptr("obs-qsv-test.exe"); struct dstr cmd = {0}; @@ -199,15 +200,15 @@ void check_adapters(struct adapter_info *adapters, size_t *adapter_count) config_adapter_count = config_num_sections(config); - if (config_adapter_count < *adapter_count) { - *adapter_count = config_adapter_count; + if (config_adapter_count < *adapter_count_out) { + *adapter_count_out = config_adapter_count; } - for (size_t i = 0; i < *adapter_count; i++) { + for (size_t i = 0; i < *adapter_count_out; i++) { char section[16]; snprintf(section, sizeof(section), "%d", (int)i); - struct adapter_info *adapter = &adapters[i]; + struct adapter_info *adapter = &adapter_info_list[i]; adapter->is_intel = config_get_bool(config, section, "is_intel"); adapter->is_dgpu = config_get_bool(config, section, "is_dgpu"); adapter->supports_av1 = config_get_bool(config, section, "supports_av1"); diff --git a/plugins/obs-qsv11/obs-qsv11.c.h b/plugins/obs-qsv11/obs-qsv11.c.h index 58e443f3b6..bd9aa14cbe 100644 --- a/plugins/obs-qsv11/obs-qsv11.c.h +++ b/plugins/obs-qsv11/obs-qsv11.c.h @@ -570,8 +570,8 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings) obsqsv->params.MaxDisplayMasteringLuminance = hdr_nominal_peak_level * 10000; obsqsv->params.MinDisplayMasteringLuminance = 0; - obsqsv->params.MaxContentLightLevel = hdr_nominal_peak_level; - obsqsv->params.MaxPicAverageLightLevel = hdr_nominal_peak_level; + obsqsv->params.MaxContentLightLevel = (mfxU16)hdr_nominal_peak_level; + obsqsv->params.MaxPicAverageLightLevel = (mfxU16)hdr_nominal_peak_level; } /* internal convenience parameter, overrides rate control param @@ -629,9 +629,9 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings) if (obsqsv->codec == QSV_CODEC_AV1) { actual_cqp *= 4; } - obsqsv->params.nQPI = actual_cqp; - obsqsv->params.nQPP = actual_cqp; - obsqsv->params.nQPB = actual_cqp; + obsqsv->params.nQPI = (mfxU16)actual_cqp; + obsqsv->params.nQPP = (mfxU16)actual_cqp; + obsqsv->params.nQPB = (mfxU16)actual_cqp; } obsqsv->params.nTargetBitRate = (mfxU16)target_bitrate; obsqsv->params.nMaxBitRate = (mfxU16)max_bitrate; diff --git a/plugins/obs-text/gdiplus/obs-text.cpp.hpp b/plugins/obs-text/gdiplus/obs-text.cpp.hpp index ed04226190..1d34736312 100644 --- a/plugins/obs-text/gdiplus/obs-text.cpp.hpp +++ b/plugins/obs-text/gdiplus/obs-text.cpp.hpp @@ -276,7 +276,7 @@ struct TextSource { void GetStringFormat(StringFormat &format); void RemoveNewlinePadding(const StringFormat &format, RectF &box); void CalculateTextSizes(const StringFormat &format, RectF &bounding_box, SIZE &text_size); - void RenderOutlineText(Graphics &graphics, const GraphicsPath &path, const Brush &brush); + void RenderOutlineText(Graphics &graphics_target, const GraphicsPath &path, const Brush &brush); void RenderText(); void LoadFileText(); void TransformText(); @@ -538,7 +538,7 @@ void TextSource::CalculateTextSizes(const StringFormat &format, RectF &bounding_ bounding_box.Height = temp_box.Height; } -void TextSource::RenderOutlineText(Graphics &graphics, const GraphicsPath &path, const Brush &brush) +void TextSource::RenderOutlineText(Graphics &graphics_target, const GraphicsPath &path, const Brush &brush) { DWORD outline_rgba = calc_color(outline_color, outline_opacity); Status stat; @@ -547,10 +547,10 @@ void TextSource::RenderOutlineText(Graphics &graphics, const GraphicsPath &path, stat = pen.SetLineJoin(LineJoinRound); warn_stat("pen.SetLineJoin"); - stat = graphics.DrawPath(&pen, &path); + stat = graphics_target.DrawPath(&pen, &path); warn_stat("graphics.DrawPath"); - stat = graphics.FillPath(&brush, &path); + stat = graphics_target.FillPath(&brush, &path); warn_stat("graphics.FillPath"); } @@ -720,7 +720,7 @@ inline void TextSource::Update(obs_data_t *s) const char *valign_str = obs_data_get_string(s, S_VALIGN); uint32_t new_color = obs_data_get_uint32(s, S_COLOR); uint32_t new_opacity = obs_data_get_uint32(s, S_OPACITY); - bool gradient = obs_data_get_bool(s, S_GRADIENT); + bool new_gradient = obs_data_get_bool(s, S_GRADIENT); uint32_t new_color2 = obs_data_get_uint32(s, S_GRADIENT_COLOR); uint32_t new_opacity2 = obs_data_get_uint32(s, S_GRADIENT_OPACITY); float new_grad_dir = (float)obs_data_get_double(s, S_GRADIENT_DIR); @@ -791,7 +791,7 @@ inline void TextSource::Update(obs_data_t *s) text_transform = new_text_transform; antialiasing = new_antialiasing; - if (!gradient) { + if (!new_gradient) { color2 = color; opacity2 = opacity; } diff --git a/plugins/text-freetype2/find-font.c.h b/plugins/text-freetype2/find-font.c.h index fffc4c380b..bc65c10bd2 100644 --- a/plugins/text-freetype2/find-font.c.h +++ b/plugins/text-freetype2/find-font.c.h @@ -292,8 +292,8 @@ void build_font_path_info(FT_Face face, FT_Long idx, const char *path) if (!family) continue; - for (size_t i = 0; i < family_names.num; i++) { - if (astrcmpi(family_names.array[i], family) == 0) { + for (size_t existing = 0; existing < family_names.num; existing++) { + if (astrcmpi(family_names.array[existing], family) == 0) { bfree(family); family = NULL; break; diff --git a/plugins/win-wasapi/win-wasapi.cpp.hpp b/plugins/win-wasapi/win-wasapi.cpp.hpp index 1337b2d7c4..05f881a32c 100644 --- a/plugins/win-wasapi/win-wasapi.cpp.hpp +++ b/plugins/win-wasapi/win-wasapi.cpp.hpp @@ -397,11 +397,11 @@ WASAPISource::WASAPISource(obs_data_t *settings, obs_source_t *source_, SourceTy } } - auto notify = GetNotify(); - if (notify) { - notify->AddDefaultDeviceChangedCallback(this, std::bind(&WASAPISource::SetDefaultDevice, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + auto notify_handler = GetNotify(); + if (notify_handler) { + notify_handler->AddDefaultDeviceChangedCallback( + this, std::bind(&WASAPISource::SetDefaultDevice, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); } Start(); @@ -451,9 +451,9 @@ void WASAPISource::Stop() WASAPISource::~WASAPISource() { - auto notify = GetNotify(); - if (notify) { - notify->RemoveDefaultDeviceChangedCallback(this); + auto notify_handler = GetNotify(); + if (notify_handler) { + notify_handler->RemoveDefaultDeviceChangedCallback(this); } // If the device is also used for monitoring, a cleanup is needed. if (sourceType == SourceType::DeviceOutput) { @@ -475,21 +475,21 @@ WASAPISource::UpdateParams WASAPISource::BuildUpdateParams(obs_data_t *settings) params.executable.clear(); if (sourceType != SourceType::Input) { const char *const window = obs_data_get_string(settings, OPT_WINDOW); - char *window_class = nullptr; - char *title = nullptr; - char *executable = nullptr; - ms_build_window_strings(window, &window_class, &title, &executable); - if (window_class) { - params.window_class = window_class; - bfree(window_class); + char *window_class_name = nullptr; + char *window_title = nullptr; + char *window_exe = nullptr; + ms_build_window_strings(window, &window_class_name, &window_title, &window_exe); + if (window_class_name) { + params.window_class = window_class_name; + bfree(window_class_name); } - if (title) { - params.title = title; - bfree(title); + if (window_title) { + params.title = window_title; + bfree(window_title); } - if (executable) { - params.executable = executable; - bfree(executable); + if (window_exe) { + params.executable = window_exe; + bfree(window_exe); } } @@ -536,15 +536,15 @@ void WASAPISource::Update(obs_data_t *settings) { UpdateParams params = BuildUpdateParams(settings); - const bool restart = (sourceType == SourceType::ProcessOutput) - ? ((priority != params.priority) || (window_class != params.window_class) || - (title != params.title) || (executable != params.executable)) - : (device_id.compare(params.device_id) != 0); + const bool should_restart = (sourceType == SourceType::ProcessOutput) + ? ((priority != params.priority) || (window_class != params.window_class) || + (title != params.title) || (executable != params.executable)) + : (device_id.compare(params.device_id) != 0); UpdateSettings(std::move(params)); LogSettings(); - if (restart) { + if (should_restart) { SetEvent(restartSignal); } } @@ -553,14 +553,14 @@ void WASAPISource::OnWindowChanged(obs_data_t *settings) { UpdateParams params = BuildUpdateParams(settings); - const bool restart = (sourceType == SourceType::ProcessOutput) - ? ((priority != params.priority) || (window_class != params.window_class) || - (title != params.title) || (executable != params.executable)) - : (device_id.compare(params.device_id) != 0); + const bool should_restart = (sourceType == SourceType::ProcessOutput) + ? ((priority != params.priority) || (window_class != params.window_class) || + (title != params.title) || (executable != params.executable)) + : (device_id.compare(params.device_id) != 0); UpdateSettings(std::move(params)); - if (restart) { + if (should_restart) { SetEvent(restartSignal); } } @@ -890,23 +890,23 @@ void WASAPISource::Initialize() signal_handler_t *sh = obs_source_get_signal_handler(source); calldata_t data = {0}; - struct dstr title = {0}; - struct dstr window_class = {0}; - struct dstr executable = {0}; + struct dstr window_title = {0}; + struct dstr window_class_name = {0}; + struct dstr window_exe = {0}; - ms_get_window_title(&title, hwnd); - ms_get_window_class(&window_class, hwnd); - ms_get_window_exe(&executable, hwnd); + ms_get_window_title(&window_title, hwnd); + ms_get_window_class(&window_class_name, hwnd); + ms_get_window_exe(&window_exe, hwnd); calldata_set_ptr(&data, "source", source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", window_class.array); - calldata_set_string(&data, "executable", executable.array); + calldata_set_string(&data, "title", window_title.array); + calldata_set_string(&data, "class", window_class_name.array); + calldata_set_string(&data, "executable", window_exe.array); signal_handler_signal(sh, "hooked", &data); - dstr_free(&title); - dstr_free(&window_class); - dstr_free(&executable); + dstr_free(&window_title); + dstr_free(&window_class_name); + dstr_free(&window_exe); calldata_free(&data); } } diff --git a/shared/properties-view/properties-view.cpp.hpp b/shared/properties-view/properties-view.cpp.hpp index 0463aeec01..f4192a26be 100644 --- a/shared/properties-view/properties-view.cpp.hpp +++ b/shared/properties-view/properties-view.cpp.hpp @@ -218,16 +218,16 @@ void OBSPropertiesView::resizeEvent(QResizeEvent *event) } template -QWidget *OBSPropertiesView::NewWidget(obs_property_t *prop, Sender *widget, void (SenderParent::*signal)(Args...)) +QWidget *OBSPropertiesView::NewWidget(obs_property_t *prop, Sender *widget_ptr, void (SenderParent::*signal)(Args...)) { const char *long_desc = obs_property_long_description(prop); - WidgetInfo *info = new WidgetInfo(this, prop, widget); - QObject::connect(widget, signal, info, &WidgetInfo::ControlChanged); + WidgetInfo *info = new WidgetInfo(this, prop, widget_ptr); + QObject::connect(widget_ptr, signal, info, &WidgetInfo::ControlChanged); children.emplace_back(info); - widget->setToolTip(QT_UTF8(long_desc)); - return widget; + widget_ptr->setToolTip(QT_UTF8(long_desc)); + return widget_ptr; } QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) @@ -240,10 +240,10 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) QCheckBox *checkbox = new QCheckBox(QT_UTF8(desc)); checkbox->setCheckState(val ? Qt::Checked : Qt::Unchecked); - QWidget *widget = NewWidget(prop, checkbox, &QCheckBox::checkStateChanged); + QWidget *widget_ptr = NewWidget(prop, checkbox, &QCheckBox::checkStateChanged); if (!long_desc) { - return widget; + return widget_ptr; } QString file = !obs_frontend_is_theme_dark() ? ":/res/images/help.svg" : ":/res/images/help_light.svg"; @@ -254,17 +254,17 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) qt_platform::tweak_checkbox(checkbox); - widget = new QWidget(); - QHBoxLayout *layout = new QHBoxLayout(widget); + widget_ptr = new QWidget(); + QHBoxLayout *layout = new QHBoxLayout(widget_ptr); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(Qt::AlignLeft); layout->setSpacing(0); layout->addWidget(checkbox); layout->addWidget(help); - widget->setLayout(layout); + widget_ptr->setLayout(layout); - return widget; + return widget_ptr; } QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, QLabel *&label) @@ -272,15 +272,15 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, Q const char *name = obs_property_name(prop); const char *val = obs_data_get_string(settings, name); bool monospace = obs_property_text_monospace(prop); - obs_text_type type = obs_property_text_type(prop); + obs_text_type text_type = obs_property_text_type(prop); - if (type == OBS_TEXT_MULTILINE) { + if (text_type == OBS_TEXT_MULTILINE) { OBSPlainTextEdit *edit = new OBSPlainTextEdit(this, monospace); edit->setPlainText(QT_UTF8(val)); edit->setTabStopDistance(40); return NewWidget(prop, edit, &OBSPlainTextEdit::textChanged); - } else if (type == OBS_TEXT_PASSWORD) { + } else if (text_type == OBS_TEXT_PASSWORD) { QLayout *subLayout = new QHBoxLayout(); QLineEdit *edit = new QLineEdit(); QPushButton *show = new QPushButton(); @@ -306,7 +306,7 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, Q connect(edit, &QLineEdit::textEdited, info, &WidgetInfo::ControlChanged); return nullptr; - } else if (type == OBS_TEXT_INFO) { + } else if (text_type == OBS_TEXT_INFO) { QString desc = QT_UTF8(obs_property_description(prop)); const char *long_desc = obs_property_long_description(prop); obs_text_info_type info_type = obs_property_text_info_type(prop); @@ -391,7 +391,7 @@ void OBSPropertiesView::AddPath(obs_property_t *prop, QFormLayout *layout, QLabe void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel **label) { - obs_number_type type = obs_property_int_type(prop); + obs_number_type int_type = obs_property_int_type(prop); QLayout *subLayout = new QHBoxLayout(); const char *name = obs_property_name(prop); @@ -415,7 +415,7 @@ void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel WidgetInfo *info = new WidgetInfo(this, prop, spin); children.emplace_back(info); - if (type == OBS_NUMBER_SLIDER) { + if (int_type == OBS_NUMBER_SLIDER) { QSlider *slider = new SliderIgnoreScroll(); slider->setMinimum(minVal); slider->setMaximum(maxVal); @@ -439,7 +439,7 @@ void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, QLabel **label) { - obs_number_type type = obs_property_float_type(prop); + obs_number_type float_type = obs_property_float_type(prop); QLayout *subLayout = new QHBoxLayout(); const char *name = obs_property_name(prop); @@ -473,7 +473,7 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, QLab WidgetInfo *info = new WidgetInfo(this, prop, spin); children.emplace_back(info); - if (type == OBS_NUMBER_SLIDER) { + if (float_type == OBS_NUMBER_SLIDER) { DoubleSlider *slider = new DoubleSlider(); slider->setDoubleConstraints(minVal, maxVal, stepVal, val); slider->setOrientation(Qt::Horizontal); @@ -588,13 +588,13 @@ static QVariant from_obs_data_autoselect(obs_data_t *data, const char *name, obs QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) { const char *name = obs_property_name(prop); - obs_combo_type type = obs_property_list_type(prop); + obs_combo_type combo_type = obs_property_list_type(prop); obs_combo_format format = obs_property_list_format(prop); size_t count = obs_property_list_item_count(prop); QVariant value = from_obs_data(settings, name, format); - if (type == OBS_COMBO_TYPE_RADIO) { + if (combo_type == OBS_COMBO_TYPE_RADIO) { QButtonGroup *buttonGroup = new QButtonGroup(); QFormLayout *subLayout = new QFormLayout(); subLayout->setContentsMargins(0, 0, 0, 0); @@ -610,9 +610,9 @@ QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) connect(buttonGroup, &QButtonGroup::buttonClicked, info, &WidgetInfo::ControlChanged); } - QWidget *widget = new QWidget(); - widget->setLayout(subLayout); - return widget; + QWidget *widget_ptr = new QWidget(); + widget_ptr->setLayout(subLayout); + return widget_ptr; } int idx = -1; @@ -622,20 +622,20 @@ QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) AddComboItem(combo, prop, i); } - if (type == OBS_COMBO_TYPE_EDITABLE) { + if (combo_type == OBS_COMBO_TYPE_EDITABLE) { combo->setEditable(true); } combo->setMaxVisibleItems(40); combo->setToolTip(QT_UTF8(obs_property_long_description(prop))); - if (format == OBS_COMBO_FORMAT_STRING && type == OBS_COMBO_TYPE_EDITABLE) { + if (format == OBS_COMBO_FORMAT_STRING && combo_type == OBS_COMBO_TYPE_EDITABLE) { combo->lineEdit()->setText(value.toString()); } else { idx = combo->findData(value); } - if (type == OBS_COMBO_TYPE_EDITABLE) { + if (combo_type == OBS_COMBO_TYPE_EDITABLE) { return NewWidget(prop, combo, &QComboBox::editTextChanged); } @@ -1372,30 +1372,30 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL int selector_mode = obs_data_get_int(settings, "fps_selector_mode"); - auto widget = CreateFrameRateWidget(prop, warning, option, selector_mode, valid_fps, fps_ranges); - auto info = new WidgetInfo(this, prop, widget); + auto widget_ptr = CreateFrameRateWidget(prop, warning, option, selector_mode, valid_fps, fps_ranges); + auto info = new WidgetInfo(this, prop, widget_ptr); - widget->setToolTip(QT_UTF8(obs_property_long_description(prop))); + widget_ptr->setToolTip(QT_UTF8(obs_property_long_description(prop))); - widget->name = name; - widget->settings = settings; + widget_ptr->name = name; + widget_ptr->settings = settings; - widget->modeSelect->setEnabled(enabled); - widget->simpleFPS->setEnabled(enabled); - widget->fpsRange->setEnabled(enabled); - widget->numEdit->setEnabled(enabled); - widget->denEdit->setEnabled(enabled); + widget_ptr->modeSelect->setEnabled(enabled); + widget_ptr->simpleFPS->setEnabled(enabled); + widget_ptr->fpsRange->setEnabled(enabled); + widget_ptr->numEdit->setEnabled(enabled); + widget_ptr->denEdit->setEnabled(enabled); - label = widget->warningLabel = new QLabel{obs_property_description(prop)}; + label = widget_ptr->warningLabel = new QLabel{obs_property_description(prop)}; - layout->addRow(label, widget); + layout->addRow(label, widget_ptr); children.emplace_back(info); - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); - auto stack = widget->modeDisplay; - auto combo = widget->modeSelect; + auto stack = widget_ptr->modeDisplay; + auto combo = widget_ptr->modeSelect; stack->setToolTip(QT_UTF8(obs_property_long_description(prop))); combo->setToolTip(QT_UTF8(obs_property_long_description(prop))); @@ -1405,40 +1405,40 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL auto idx = out_of_bounds ? stack->count() - 1 : index; stack->setCurrentIndex(idx); - if (widget->updating) { + if (widget_ptr->updating) { return; } - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); emit info->ControlChanged(); }); - connect(widget->simpleFPS, &QComboBox::currentIndexChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->simpleFPS, &QComboBox::currentIndexChanged, info, [=](int) { + if (widget_ptr->updating) { return; } emit info->ControlChanged(); }); - connect(widget->fpsRange, &QComboBox::currentIndexChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->fpsRange, &QComboBox::currentIndexChanged, info, [=](int) { + if (widget_ptr->updating) { return; } - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); }); - connect(widget->numEdit, &QSpinBox::valueChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->numEdit, &QSpinBox::valueChanged, info, [=](int) { + if (widget_ptr->updating) { return; } emit info->ControlChanged(); }); - connect(widget->denEdit, &QSpinBox::valueChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->denEdit, &QSpinBox::valueChanged, info, [=](int) { + if (widget_ptr->updating) { return; } @@ -1451,11 +1451,11 @@ void OBSPropertiesView::AddGroup(obs_property_t *prop, QFormLayout *layout) const char *name = obs_property_name(prop); bool val = obs_data_get_bool(settings, name); const char *desc = obs_property_description(prop); - enum obs_group_type type = obs_property_group_type(prop); + enum obs_group_type group_type = obs_property_group_type(prop); // Create GroupBox QGroupBox *groupBox = new QGroupBox(QT_UTF8(desc)); - groupBox->setCheckable(type == OBS_GROUP_CHECKABLE); + groupBox->setCheckable(group_type == OBS_GROUP_CHECKABLE); groupBox->setChecked(groupBox->isCheckable() ? val : true); groupBox->setAccessibleName("group"); groupBox->setEnabled(obs_property_enabled(prop)); @@ -1486,21 +1486,21 @@ void OBSPropertiesView::AddGroup(obs_property_t *prop, QFormLayout *layout) void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layout) { const char *name = obs_property_name(property); - obs_property_type type = obs_property_get_type(property); + obs_property_type prop_type = obs_property_get_type(property); if (!obs_property_visible(property)) { return; } QLabel *label = nullptr; - QWidget *widget = nullptr; + QWidget *widget_ptr = nullptr; bool warning = false; - switch (type) { + switch (prop_type) { case OBS_PROPERTY_INVALID: return; case OBS_PROPERTY_BOOL: - widget = AddCheckbox(property); + widget_ptr = AddCheckbox(property); break; case OBS_PROPERTY_INT: AddInt(property, layout, &label); @@ -1509,13 +1509,13 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddFloat(property, layout, &label); break; case OBS_PROPERTY_TEXT: - widget = AddText(property, layout, label); + widget_ptr = AddText(property, layout, label); break; case OBS_PROPERTY_PATH: AddPath(property, layout, &label); break; case OBS_PROPERTY_LIST: - widget = AddList(property, warning); + widget_ptr = AddList(property, warning); break; case OBS_PROPERTY_COLOR: AddColor(property, layout, label); @@ -1524,7 +1524,7 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddFont(property, layout, label); break; case OBS_PROPERTY_BUTTON: - widget = AddButton(property); + widget_ptr = AddButton(property); break; case OBS_PROPERTY_EDITABLE_LIST: AddEditableList(property, layout, label); @@ -1539,11 +1539,12 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddColorAlpha(property, layout, label); } - if (!widget && !label) { + if (!widget_ptr && !label) { return; } - if (!label && type != OBS_PROPERTY_BOOL && type != OBS_PROPERTY_BUTTON && type != OBS_PROPERTY_GROUP) { + if (!label && prop_type != OBS_PROPERTY_BOOL && prop_type != OBS_PROPERTY_BUTTON && + prop_type != OBS_PROPERTY_GROUP) { label = new QLabel(QT_UTF8(obs_property_description(property))); } @@ -1562,12 +1563,12 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou } } - if (!widget) { + if (!widget_ptr) { return; } if (!obs_property_enabled(property)) { - widget->setEnabled(false); + widget_ptr->setEnabled(false); } QWidget *leftWidget = label; @@ -1591,11 +1592,11 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou leftWidget = newWidget; } - layout->addRow(leftWidget, widget); + layout->addRow(leftWidget, widget_ptr); if (!lastFocused.empty()) { if (lastFocused.compare(name) == 0) { - lastWidget = widget; + lastWidget = widget_ptr; } } } From 790258436e32900a3a9119e9296dd35e11c667f4 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:26:39 -0700 Subject: [PATCH 22/63] test(msvc): require the product C++ targets to carry the C4201 exemption (#2626) RED: on the previous commit this test fails three ways - the obs_msvc_exempt_c4201 helper does not exist, none of the nine product C++ targets opt in, and the decklink/swig exemptions are absent. It pins the #2626 decision for C4201: a per-target /wd4201 for the C++ targets that include libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h or frontend/api/obs-frontend-api.h, never a blanket /wd4201 in the MSVC config. Refs #2626. --- ci/test_msvc_warning_level.py | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 9ce9880b24..f18ecbb2c6 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -50,5 +50,61 @@ def test_wx_comes_from_the_compile_time_setting(self) -> None: self.assertNotIn("/WX", call_tokens(self.text, "add_compile_options")) +HELPERS = ROOT / "cmake" / "common" / "helpers_common.cmake" + +# Every product C++ target that compiles a translation unit including +# libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h or +# frontend/api/obs-frontend-api.h, and so reports C4201 at /W4. The warnings come +# from the headers, not from the target's own code, and the nameless unions in +# them are legal C11 (6.7.2.1p13) consumed from C, so #2626 decided a per-target +# exemption for exactly these targets rather than renaming the types (an API +# break) or disabling C4201 for every C++ target. +C4201_TARGETS = { + "aja-output-ui": "plugins/aja-output-ui/CMakeLists.txt", + "coreaudio-encoder": "plugins/coreaudio-encoder/CMakeLists.txt", + "decklink": "plugins/decklink/CMakeLists.txt", + "decklink-output-ui": "plugins/decklink-output-ui/CMakeLists.txt", + "frontend-tools": "plugins/frontend-tools/CMakeLists.txt", + "libobs-d3d11": "libobs-d3d11/CMakeLists.txt", + "obs-studio": "frontend/CMakeLists.txt", + "obs-browser": "plugins/CMakeLists.txt", + "obs-vst": "plugins/obs-vst/CMakeLists.txt", + "obs-websocket": "plugins/CMakeLists.txt", +} + + +class MsvcNamelessUnionExemptionTest(unittest.TestCase): + """C4201 is exempted per target, for the C++ targets that include those headers.""" + + def test_helper_is_cxx_and_msvc_scoped(self) -> None: + text = HELPERS.read_text(encoding="utf-8") + self.assertIn("function(obs_msvc_exempt_c4201 target)", text) + helper = text.split("function(obs_msvc_exempt_c4201 target)", 1)[1].split("endfunction()", 1)[0] + self.assertIn("/wd4201", helper) + self.assertIn("COMPILE_LANG_AND_ID:CXX,MSVC", helper) + + def test_no_blanket_exemption_in_the_msvc_config(self) -> None: + windows = WINDOWS.read_text(encoding="utf-8") + self.assertIsNone( + re.search(r"(? None: + obslua = (ROOT / "shared" / "obs-scripting" / "obslua" / "CMakeLists.txt").read_text(encoding="utf-8") + for flag in ("/wd4100", "/wd4189"): + self.assertIn(flag, obslua, "the SWIG-generated wrapper is not edited by hand") + decklink = (ROOT / "plugins" / "decklink" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertIn("/wd4324", decklink, "FrameQueue pads for false-sharing avoidance") + + def test_each_product_cxx_target_opts_in(self) -> None: + missing = [] + for target, relative in sorted(C4201_TARGETS.items()): + body = (ROOT / relative).read_text(encoding="utf-8") + if f"obs_msvc_exempt_c4201({target})" not in body: + missing.append(f"{relative}: {target}") + self.assertEqual(missing, []) + + if __name__ == "__main__": unittest.main() From c03d89c60c752cf4f9c6166391890f94528ee52b Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:26:39 -0700 Subject: [PATCH 23/63] build(msvc): exempt C4201 per product C++ target and pin the app-lane classes (#2626) GREEN for the test in the previous commit. /W4 reports C4201 for the nameless unions in libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h and frontend/api/obs-frontend-api.h in every C++ TU that includes them. Those unions are legal C11 (6.7.2.1p13) and consumed from C, so naming them is an API break; the decision on #2626 is a per-target exemption, not a blanket one. - obs_msvc_exempt_c4201() in cmake/common/helpers_common.cmake: one /wd4201 under $, so it is inert everywhere else. - opt in from aja-output-ui, coreaudio-encoder, decklink, decklink-output-ui, frontend-tools, libobs-d3d11, the frontend (obs-studio), obs-vst, win-capture/graphics-hook (its own anonymous union), and - because the targets are defined by submodules - obs-browser and obs-websocket from plugins/CMakeLists.txt. - two more app-lane classes, both intentional: /wd4324 on decklink (FrameQueue pads to a cache line) and /wd4100 + /wd4189 on obslua, whose only source is the SWIG-generated wrapper. Refs #2626. --- cmake/common/helpers_common.cmake | 12 ++++++++++++ frontend/CMakeLists.txt | 1 + libobs-d3d11/CMakeLists.txt | 1 + plugins/CMakeLists.txt | 8 ++++++++ plugins/aja-output-ui/CMakeLists.txt | 1 + plugins/coreaudio-encoder/CMakeLists.txt | 1 + plugins/decklink-output-ui/CMakeLists.txt | 1 + plugins/decklink/CMakeLists.txt | 5 +++++ plugins/frontend-tools/CMakeLists.txt | 1 + plugins/obs-vst/CMakeLists.txt | 1 + plugins/win-capture/graphics-hook/CMakeLists.txt | 1 + shared/obs-scripting/obslua/CMakeLists.txt | 4 ++++ 12 files changed, 37 insertions(+) diff --git a/cmake/common/helpers_common.cmake b/cmake/common/helpers_common.cmake index 3ecafcb260..463d7533f4 100644 --- a/cmake/common/helpers_common.cmake +++ b/cmake/common/helpers_common.cmake @@ -96,6 +96,18 @@ function(target_disable target) set_property(GLOBAL APPEND PROPERTY OBS_MODULES_DISABLED ${target}) endfunction() +# obs_msvc_exempt_c4201: Disable C4201 on one C++ target (MSVC /W4, #2626) +# +# /W4 reports C4201 "nameless struct/union" for the unions in +# libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h and +# frontend/api/obs-frontend-api.h. They are legal C11 (6.7.2.1p13) and consumed +# from C, so naming them is an API break; #2626 therefore decided on a +# per-target exemption, only for the C++ targets that include those headers and +# never as a blanket /wd4201 for every C++ target. +function(obs_msvc_exempt_c4201 target) + target_compile_options(${target} PRIVATE $<$:/wd4201>) +endfunction() + # _handle_generator_expression_dependency: Helper function to yield dependency from a generator expression function(_handle_generator_expression_dependency library) set(oneValueArgs FOUND_VAR) diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt index a4a446fda8..13210103ec 100644 --- a/frontend/CMakeLists.txt +++ b/frontend/CMakeLists.txt @@ -30,6 +30,7 @@ endif() add_executable(obs-studio) add_executable(OBS::studio ALIAS obs-studio) +obs_msvc_exempt_c4201(obs-studio) include(cmake/sources.cmake) diff --git a/libobs-d3d11/CMakeLists.txt b/libobs-d3d11/CMakeLists.txt index 55d92854be..d1c6fdee29 100644 --- a/libobs-d3d11/CMakeLists.txt +++ b/libobs-d3d11/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.28...3.30) add_library(libobs-d3d11 MODULE) add_library(OBS::libobs-d3d11 ALIAS libobs-d3d11) +obs_msvc_exempt_c4201(libobs-d3d11) # Unity group (BUILD.md): build/d3d11.core+.hpp.cpp #includes the # implementation files (d3d11-foo.cpp.hpp) behind one precompiled header. diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 64697897c0..0831917064 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -22,6 +22,11 @@ macro(check_obs_browser) message(FATAL_ERROR "Required submodule 'obs-browser' not available.") else() add_core_module(obs-browser) + # The submodule's C++ sources include libobs/graphics/vec{2,3,4}.h and + # libobs/util/profiler.h, whose nameless unions C4201 flags; the target is + # defined by the submodule's own CMakeLists, so the exemption is applied + # here (#2626). + obs_msvc_exempt_c4201(obs-browser) endif() else() add_custom_target(obs-browser) @@ -34,6 +39,9 @@ macro(check_obs_websocket) message(FATAL_ERROR "Required submodule 'obs-websocket' not available.") else() add_core_module(obs-websocket) + # Same C4201 exemption as obs-browser: the target comes from the submodule + # (#2626). + obs_msvc_exempt_c4201(obs-websocket) endif() endmacro() diff --git a/plugins/aja-output-ui/CMakeLists.txt b/plugins/aja-output-ui/CMakeLists.txt index a236793482..fec1747f9a 100644 --- a/plugins/aja-output-ui/CMakeLists.txt +++ b/plugins/aja-output-ui/CMakeLists.txt @@ -22,6 +22,7 @@ endif() add_library(aja-output-ui MODULE) add_library(OBS::aja-output-ui ALIAS aja-output-ui) +obs_msvc_exempt_c4201(aja-output-ui) target_sources(aja-output-ui PRIVATE build/aja-output-ui.core+.hpp.cpp aja-ui-main.h AJAOutputUI.h) diff --git a/plugins/coreaudio-encoder/CMakeLists.txt b/plugins/coreaudio-encoder/CMakeLists.txt index decf7a6fe0..540adcc247 100644 --- a/plugins/coreaudio-encoder/CMakeLists.txt +++ b/plugins/coreaudio-encoder/CMakeLists.txt @@ -9,6 +9,7 @@ endif() add_library(coreaudio-encoder MODULE) add_library(OBS::coreaudio-encoder ALIAS coreaudio-encoder) +obs_msvc_exempt_c4201(coreaudio-encoder) # SDK types and deleters belong to one host; the Windows imports/functions # must share a translation unit with the encoder that calls them. diff --git a/plugins/decklink-output-ui/CMakeLists.txt b/plugins/decklink-output-ui/CMakeLists.txt index c270c1be52..571ed0c57d 100644 --- a/plugins/decklink-output-ui/CMakeLists.txt +++ b/plugins/decklink-output-ui/CMakeLists.txt @@ -12,6 +12,7 @@ endif() add_library(decklink-output-ui MODULE) add_library(OBS::decklink-output-ui ALIAS decklink-output-ui) +obs_msvc_exempt_c4201(decklink-output-ui) if(NOT TARGET OBS::properties-view) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/properties-view" "${CMAKE_BINARY_DIR}/shared/properties-view") diff --git a/plugins/decklink/CMakeLists.txt b/plugins/decklink/CMakeLists.txt index 95d3a556e5..1a01c48b12 100644 --- a/plugins/decklink/CMakeLists.txt +++ b/plugins/decklink/CMakeLists.txt @@ -7,6 +7,11 @@ endif() add_library(decklink MODULE) add_library(OBS::decklink ALIAS decklink) +obs_msvc_exempt_c4201(decklink) +# MSVC /W4 (#2626): FrameQueue pads its nodes to a cache line so producers and +# consumers do not share one (decklink-device-instance.hpp), so the padding +# C4324 reports there is the intent, not slack in a struct layout. +target_compile_options(decklink PRIVATE $<$:/wd4324>) add_library(decklink-sdk INTERFACE) add_library(Decklink::SDK ALIAS decklink-sdk) diff --git a/plugins/frontend-tools/CMakeLists.txt b/plugins/frontend-tools/CMakeLists.txt index a50ddf3fd4..6b79be8848 100644 --- a/plugins/frontend-tools/CMakeLists.txt +++ b/plugins/frontend-tools/CMakeLists.txt @@ -13,6 +13,7 @@ endif() add_library(frontend-tools MODULE) add_library(OBS::frontend-tools ALIAS frontend-tools) +obs_msvc_exempt_c4201(frontend-tools) if(NOT TARGET OBS::properties-view) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/properties-view" "${CMAKE_BINARY_DIR}/shared/properties-view") diff --git a/plugins/obs-vst/CMakeLists.txt b/plugins/obs-vst/CMakeLists.txt index 8348e4763b..0a3db9fe8b 100644 --- a/plugins/obs-vst/CMakeLists.txt +++ b/plugins/obs-vst/CMakeLists.txt @@ -8,6 +8,7 @@ endif() add_library(obs-vst MODULE) add_library(OBS::vst ALIAS obs-vst) +obs_msvc_exempt_c4201(obs-vst) find_package(Qt6 REQUIRED Widgets) diff --git a/plugins/win-capture/graphics-hook/CMakeLists.txt b/plugins/win-capture/graphics-hook/CMakeLists.txt index 5073134195..1c45960c0d 100644 --- a/plugins/win-capture/graphics-hook/CMakeLists.txt +++ b/plugins/win-capture/graphics-hook/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(graphics-hook MODULE) # batches (cmake/common/unity.cmake). set_property(TARGET graphics-hook PROPERTY OBS_DISABLE_UNITY_BUILD ON) add_library(OBS::graphics-hook ALIAS graphics-hook) +obs_msvc_exempt_c4201(graphics-hook) target_sources( graphics-hook diff --git a/shared/obs-scripting/obslua/CMakeLists.txt b/shared/obs-scripting/obslua/CMakeLists.txt index 170132e06e..326de8e8ea 100644 --- a/shared/obs-scripting/obslua/CMakeLists.txt +++ b/shared/obs-scripting/obslua/CMakeLists.txt @@ -26,6 +26,10 @@ target_compile_options( $<$:/wd4197> $<$:/wd4244> $<$:/wd4267> + # MSVC /W4 (#2626): the wrapper also leaves its IStream-style parameters + # unreferenced (C4100) and declares locals only to convert them (C4189). + $<$:/wd4100> + $<$:/wd4189> $<$:-Wno-shorten-64-to-32> $<$:-Wno-unreachable-code> $<$:-Wno-maybe-uninitialized> From 482a858708e595654db7f3541d3c3dd15a5c5267 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:34:53 -0700 Subject: [PATCH 24/63] test(msvc): pin the C4201 helper as a no-op without a target (#2626) ENABLE_BROWSER=OFF and ENABLE_WEBSOCKET=OFF make the submodule's CMakeLists return before add_library, so obs_msvc_exempt_c4201() is called on a target that does not exist and configure dies with "Cannot specify compile options for target ... which is not built by this project" (Qt Frontend Linux lane). RED: the guard is absent, so this fails with AssertionError: -1 == -1. --- ci/test_msvc_warning_level.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index f18ecbb2c6..039572ca16 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -83,6 +83,14 @@ def test_helper_is_cxx_and_msvc_scoped(self) -> None: self.assertIn("/wd4201", helper) self.assertIn("COMPILE_LANG_AND_ID:CXX,MSVC", helper) + def test_helper_is_a_no_op_when_the_module_is_disabled(self) -> None: + """ENABLE_BROWSER=OFF / ENABLE_WEBSOCKET=OFF leave no target to exempt.""" + text = HELPERS.read_text(encoding="utf-8") + helper = text.split("function(obs_msvc_exempt_c4201 target)", 1)[1].split("endfunction()", 1)[0] + guard = helper.find("if(NOT TARGET ${target})") + self.assertNotEqual(guard, -1, "the helper must tolerate a target the config did not create") + self.assertLess(guard, helper.find("target_compile_options"), "return before touching the target") + def test_no_blanket_exemption_in_the_msvc_config(self) -> None: windows = WINDOWS.read_text(encoding="utf-8") self.assertIsNone( From 7c72f5ce9e2199e281ec33b4c354fee06b92ba61 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:36:30 -0700 Subject: [PATCH 25/63] build(msvc): make the C4201 helper a no-op when the module is disabled (#2626) ENABLE_BROWSER=OFF and ENABLE_WEBSOCKET=OFF return from the submodule's CMakeLists before add_library, so obs_msvc_exempt_c4201() was called on a target the config never created and configure died with "Cannot specify compile options for target ... which is not built by this project". GREEN for e647e45c8: ci/test_msvc_warning_level.py -> OK (9 tests), gersemi clean. Reproduced standalone with CMake 4.1.6: without the guard configure exits 1 on the same message, with it both ENABLE_* states configure. --- cmake/common/helpers_common.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/common/helpers_common.cmake b/cmake/common/helpers_common.cmake index 463d7533f4..de31b2e3b2 100644 --- a/cmake/common/helpers_common.cmake +++ b/cmake/common/helpers_common.cmake @@ -105,6 +105,12 @@ endfunction() # per-target exemption, only for the C++ targets that include those headers and # never as a blanket /wd4201 for every C++ target. function(obs_msvc_exempt_c4201 target) + # The module options (ENABLE_BROWSER, ENABLE_WEBSOCKET, ...) make a submodule's + # CMakeLists return before add_library, so the target exists only when that + # module is actually built; nothing to exempt otherwise. + if(NOT TARGET ${target}) + return() + endif() target_compile_options(${target} PRIVATE $<$:/wd4201>) endfunction() From b4f71c65bb7e1814f3b96a4f72bbbb982bc057c9 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 20:45:15 -0700 Subject: [PATCH 26/63] fix(msvc): write the graphics-hook C4201 exemption inline (#2626) Run 40626724707 failed configuration on the previous commit: CMake Error at plugins/win-capture/graphics-hook/CMakeLists.txt:28 (obs_msvc_exempt_c4201): Unknown CMake command "obs_msvc_exempt_c4201". graphics-hook is configured by the child architecture build (cmake/windows/architecture.cmake) as well as by the main tree, and the child build adds only libobs and the win-capture/win-dshow module directories - it never includes cmake/common/helpers_common.cmake, where the helper is defined. The exemption is now an inline target_compile_options on that target, and the test pins both halves: the hook file must not name the helper, and architecture.cmake must still add the hook's directory. Refs #2626. --- ci/test_msvc_warning_level.py | 10 ++++++++++ plugins/win-capture/graphics-hook/CMakeLists.txt | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 039572ca16..1e036b47ec 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -98,6 +98,16 @@ def test_no_blanket_exemption_in_the_msvc_config(self) -> None: "the MSVC config must not disable C4201 for every C++ target", ) + def test_child_configured_targets_use_inline_flags(self) -> None: + # The child architecture build configures win-capture/graphics-hook (and + # friends) without cmake/common/helpers_common.cmake, so an + # obs_msvc_exempt_c4201() call there fails configuration. + hook = (ROOT / "plugins" / "win-capture" / "graphics-hook" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertNotIn("obs_msvc_exempt_c4201", hook) + self.assertIn("/wd4201", hook) + child = (ROOT / "cmake" / "windows" / "architecture.cmake").read_text(encoding="utf-8") + self.assertIn("add_subdirectory(plugins/win-capture/graphics-hook)", child) + def test_generated_wrapper_and_padded_queue_exemptions(self) -> None: obslua = (ROOT / "shared" / "obs-scripting" / "obslua" / "CMakeLists.txt").read_text(encoding="utf-8") for flag in ("/wd4100", "/wd4189"): diff --git a/plugins/win-capture/graphics-hook/CMakeLists.txt b/plugins/win-capture/graphics-hook/CMakeLists.txt index 1c45960c0d..a0ca65fa60 100644 --- a/plugins/win-capture/graphics-hook/CMakeLists.txt +++ b/plugins/win-capture/graphics-hook/CMakeLists.txt @@ -25,7 +25,12 @@ add_library(graphics-hook MODULE) # batches (cmake/common/unity.cmake). set_property(TARGET graphics-hook PROPERTY OBS_DISABLE_UNITY_BUILD ON) add_library(OBS::graphics-hook ALIAS graphics-hook) -obs_msvc_exempt_c4201(graphics-hook) +# MSVC /W4 (#2626): this target is also configured by the child architecture +# build (cmake/windows/architecture.cmake), which does not include +# cmake/common/helpers_common.cmake, so the C4201 exemption is written inline +# here instead of through the per-target helper. d3d10-capture.cpp.hpp's state +# is an anonymous union over two struct overlays by design. +target_compile_options(graphics-hook PRIVATE $<$:/wd4201>) target_sources( graphics-hook From 67a2092722bbfc5bee12cd984e3496d41a4ecba1 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 21:02:43 -0700 Subject: [PATCH 27/63] fix(msvc): clear the wave 7 /W4 findings from the Windows app lane (#2626) Run 40628508954 compiled past configure and reported the next class, all first-party: - aja-output-ui: three `OBSData data` locals hid QWidget::data (C4458) and three `cardManager` declarations hid the file-static global (C4459); inner names only. - graphics-hook/gl-capture: the blacklist lookup's `process_name` hid the global (C4459). - obs-ffmpeg-mpegts: `to_join` is assigned under `have_to_join` and only read under it, but MSVC cannot correlate the flag across the mutex unlock (C4701); it is now `= {0}`. - obs-nvenc: `enableLookahead` is a uint32_t assigned to a bool (C4244) - now `!= 0`, which is exactly what the implicit conversion did; `lookaheadDepth` gets the explicit uint16_t cast its NVENC field already required. Two findings in this wave are submodule code and are fixed there instead: obs-browser (obs-rust/obs-browser#15) and obs-websocket's onMessage (obs-rust/obs-websocket#24). The vendored librtmp class stays with the maintainer (part 1 of the escalation on #2626). Refs #2626. --- plugins/aja-output-ui/AJAOutputUI.cpp.hpp | 18 +++++++++--------- plugins/aja-output-ui/aja-ui-main.cpp.hpp | 16 ++++++++-------- plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h | 2 +- plugins/obs-nvenc/nvenc.c.h | 2 +- .../win-capture/graphics-hook/gl-capture.c.h | 7 ++++--- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/plugins/aja-output-ui/AJAOutputUI.cpp.hpp b/plugins/aja-output-ui/AJAOutputUI.cpp.hpp index f527de0d9d..7f616f4b1d 100644 --- a/plugins/aja-output-ui/AJAOutputUI.cpp.hpp +++ b/plugins/aja-output-ui/AJAOutputUI.cpp.hpp @@ -27,9 +27,9 @@ void AJAOutputUI::SetupPropertiesView() } obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kProgramPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kProgramPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } else { // apply default settings obs_data_set_default_int(settings, kUIPropOutput.id, static_cast(IOSelection::Invalid)); @@ -76,9 +76,9 @@ void AJAOutputUI::SetupPreviewPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kPreviewPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kPreviewPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } else { // apply default settings obs_data_set_default_int(settings, kUIPropOutput.id, static_cast(IOSelection::Invalid)); @@ -224,9 +224,9 @@ void AJAOutputUI::SetupMiscPropertiesView() } obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kMiscPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kMiscPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } miscPropertiesView = new OBSPropertiesView(settings, this, (PropertiesReloadCallback)create_misc_props_ui, diff --git a/plugins/aja-output-ui/aja-ui-main.cpp.hpp b/plugins/aja-output-ui/aja-ui-main.cpp.hpp index e2036b9a6b..94d4256309 100644 --- a/plugins/aja-output-ui/aja-ui-main.cpp.hpp +++ b/plugins/aja-output-ui/aja-ui-main.cpp.hpp @@ -165,9 +165,9 @@ void preview_output_toggle() } } -void populate_misc_device_list(obs_property_t *list, aja::CardManager *cardManager, NTV2DeviceID &firstDeviceID) +void populate_misc_device_list(obs_property_t *list, aja::CardManager *card_manager, NTV2DeviceID &firstDeviceID) { - for (const auto &iter : *cardManager) { + for (const auto &iter : *card_manager) { if (!iter.second) { continue; } @@ -202,11 +202,11 @@ bool on_misc_device_selected(void *data, obs_properties_t *props, obs_property_t if (!cardID || !cardID[0]) { return false; } - aja::CardManager *cardManager = (aja::CardManager *)data; - if (!cardManager) { + aja::CardManager *card_manager_local = (aja::CardManager *)data; + if (!card_manager_local) { return false; } - auto cardEntry = cardManager->GetCardEntry(cardID); + auto cardEntry = card_manager_local->GetCardEntry(cardID); if (!cardEntry) { return false; } @@ -267,11 +267,11 @@ bool on_multi_view_toggle(void *data, obs_properties_t *, obs_property_t *, obs_ if (!cardID || !cardID[0]) { return false; } - aja::CardManager *cardManager = (aja::CardManager *)data; - if (!cardManager) { + aja::CardManager *card_manager_local = (aja::CardManager *)data; + if (!card_manager_local) { return false; } - CNTV2Card *card = cardManager->GetCard(cardID); + CNTV2Card *card = card_manager_local->GetCard(cardID); if (!card) { return false; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h index 39520afec5..cd783215f0 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h @@ -1131,7 +1131,7 @@ static void ffmpeg_mpegts_stop_internal(void *data, uint64_t ts, bool signal) cmd->ts = ts; bool have_to_join = false; - pthread_t to_join; + pthread_t to_join = {0}; os_atomic_set_bool(&stream->abort_connect, true); diff --git a/plugins/obs-nvenc/nvenc.c.h b/plugins/obs-nvenc/nvenc.c.h index 5db7dfd882..7703f860f1 100644 --- a/plugins/obs-nvenc/nvenc.c.h +++ b/plugins/obs-nvenc/nvenc.c.h @@ -306,7 +306,7 @@ static bool init_encoder_base(struct nvenc_data *enc, obs_data_t *settings) * checkbox and the Enhanced Broadcasting override both write the key. * When the key is absent, the preset may still enable lookahead. */ const bool lookahead_explicit = enc->props.data && obs_data_has_user_value(enc->props.data, "lookahead"); - const bool use_profile_lookahead = config->rcParams.enableLookahead; + const bool use_profile_lookahead = config->rcParams.enableLookahead != 0; bool lookahead = nv_get_cap(enc, NV_ENC_CAPS_SUPPORT_LOOKAHEAD) && nvenc_lookahead_enabled(use_profile_lookahead, lookahead_explicit, enc->props.lookahead); diff --git a/plugins/win-capture/graphics-hook/gl-capture.c.h b/plugins/win-capture/graphics-hook/gl-capture.c.h index fc0c09a81c..7f074617cb 100644 --- a/plugins/win-capture/graphics-hook/gl-capture.c.h +++ b/plugins/win-capture/graphics-hook/gl-capture.c.h @@ -813,9 +813,10 @@ bool hook_gl(void) /* "life is feudal: your own" somehow uses both opengl and directx at * the same time, so blacklist it from capturing opengl */ - const char *process_name = get_process_name(); - if (_strcmpi(process_name, "yo_cm_client.exe") == 0 || _strcmpi(process_name, "cm_client.exe") == 0) { - hlog("Ignoring opengl for game: %s", process_name); + const char *process_name_local = get_process_name(); + if (_strcmpi(process_name_local, "yo_cm_client.exe") == 0 || + _strcmpi(process_name_local, "cm_client.exe") == 0) { + hlog("Ignoring opengl for game: %s", process_name_local); return true; } From 78003eb38b932d1136c3c4fd2dc41c8d5e7b328c Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 21:34:20 -0700 Subject: [PATCH 28/63] test(msvc): pin the submodule pointers that carry the wave 6-7 /W4 renames (#2626) The app lane's remaining expected reds were the two submodule targets. Their fixes are merged in obs-rust/obs-browser#15 (C4457 frame, C4456 args) and obs-rust/obs-websocket#24 (C4456 errorCode x2); this pins each pointer at or above those commits so a later pointer move cannot silently reintroduce the findings. --- ci/test_browser_submodule.py | 56 ++++++++++++++++++++++++++++++++++ ci/test_websocket_submodule.py | 6 ++++ 2 files changed, 62 insertions(+) create mode 100644 ci/test_browser_submodule.py diff --git a/ci/test_browser_submodule.py b/ci/test_browser_submodule.py new file mode 100644 index 0000000000..54f1741661 --- /dev/null +++ b/ci/test_browser_submodule.py @@ -0,0 +1,56 @@ +#!/usr/bin/env -S uv run --script +"""plugins/obs-browser must point at a commit that carries the /W4 shadowing fixes. + + uv run python -m unittest ci/test_browser_submodule.py + +The MSVC ``/W4`` ratchet (#2626) reports ``browser-app.cpp``'s shadowing locals in +the app build, which no PR path compiles. Those two fixes live in the submodule +(obs-rust/obs-browser#15), so the product build only becomes clean once this +checkout's pointer is at that commit or a descendant of it. A pointer that moves +back to an older submodule commit silently reintroduces the C4456/C4457 findings. +""" + +from __future__ import annotations + +import subprocess +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +SUBMODULE = "plugins/obs-browser" +# obs-rust/obs-browser#15: rename the browser-app locals that hide a parameter +# and a local (C4457 `frame`, C4456 `args`) for obs-studio#2626. +WARNING_SHADOWING_FIX = "b9c5db137711717bc02cdd265801ad26f270bd66" + + +def git(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess: + return subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True, check=False) + + +class BrowserSubmoduleTest(unittest.TestCase): + def test_pointer_keeps_the_warning_renames(self) -> None: + tree = git("ls-tree", "HEAD", SUBMODULE).stdout.split() + self.assertEqual(tree[:2], ["160000", "commit"], f"{SUBMODULE} is not a submodule") + pointer = tree[2] + if pointer == WARNING_SHADOWING_FIX: + return + sub = ROOT / SUBMODULE + if not (sub / ".git").exists(): + self.skipTest(f"{SUBMODULE} is not checked out; cannot check ancestry of {pointer}") + has = git("merge-base", "--is-ancestor", WARNING_SHADOWING_FIX, pointer, cwd=sub) + if has.returncode != 0: + known = git("cat-file", "-e", f"{WARNING_SHADOWING_FIX}^{{commit}}", cwd=sub).returncode == 0 + shallow = git("rev-parse", "--is-shallow-repository", cwd=sub).stdout.strip() == "true" + if not known and shallow: + # A shallow checkout may stop above the fix, so a miss here proves nothing. + self.skipTest(f"{SUBMODULE} history is shallow; cannot check ancestry of {pointer[:9]}") + self.assertEqual( + has.returncode, + 0, + f"{SUBMODULE} points at {pointer[:9]}, which lacks the /W4 shadowing renames " + f"({WARNING_SHADOWING_FIX[:9]})", + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/ci/test_websocket_submodule.py b/ci/test_websocket_submodule.py index 30f1866afc..3bdcd87483 100644 --- a/ci/test_websocket_submodule.py +++ b/ci/test_websocket_submodule.py @@ -21,6 +21,9 @@ # obs-rust/obs-websocket#22: Stop() reads the drain predicate under the session # mutex and bounds the wait (obs-studio#2713). BOUNDED_SESSION_DRAIN = "3253206ff1ba62213936f4e9458e0ebf5eb421ea" +# obs-rust/obs-websocket#24: rename the two inner errorCode locals in onMessage +# (C4456) for the MSVC /W4 ratchet (obs-studio#2626), which the app build reports. +WARNING_SHADOWING_FIX = "960b99e702f116f9cc80ff6b2d3741dc917b7d87" # Upstream commits without the fix that stale checkouts have committed (#492, #496). KNOWN_BAD = {"073a294cd0646fa1744b0ebf3293bfa63a869b50"} @@ -59,6 +62,9 @@ def test_pointer_keeps_the_bounded_parser(self): def test_pointer_keeps_the_bounded_session_drain(self): self._assert_pointer_at_least(BOUNDED_SESSION_DRAIN, "the bounded session drain (#2713)") + def test_pointer_keeps_the_warning_renames(self): + self._assert_pointer_at_least(WARNING_SHADOWING_FIX, "the /W4 shadowing renames (#24)") + class SessionDrainShapeTest(unittest.TestCase): """Stop() must read the drain predicate under the session mutex and bound the wait.""" From 7c05aebd41dc4615289cf357cd0142241020f8ca Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 21:34:30 -0700 Subject: [PATCH 29/63] build(msvc): bump the submodules to the wave 6-7 /W4 renames (#2626) obs-browser b9c5db13 (obs-rust/obs-browser#15) and obs-websocket 960b99e7 (obs-rust/obs-websocket#24) both descend from master's pointers, so these bumps are fast-forwards of the submodule history, not rebases of it. --- plugins/obs-browser | 2 +- plugins/obs-websocket | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/obs-browser b/plugins/obs-browser index 434cc38501..b9c5db1377 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit 434cc3850178072ba41a49582b7538852315aca4 +Subproject commit b9c5db137711717bc02cdd265801ad26f270bd66 diff --git a/plugins/obs-websocket b/plugins/obs-websocket index 777071b5db..960b99e702 160000 --- a/plugins/obs-websocket +++ b/plugins/obs-websocket @@ -1 +1 @@ -Subproject commit 777071b5db3dc3cf0fd62f3cea5a2a3ac7992af2 +Subproject commit 960b99e702f116f9cc80ff6b2d3741dc917b7d87 From 43b5dc951aca95444d696dc6c55542e4692c6199 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 21:38:50 -0700 Subject: [PATCH 30/63] fix(msvc): clear the wave 8 /W4 findings from the Windows app lane (#2626) New classes only the app build compiles: - inject-helper C4152: the obfuscated open_process lookup assigned a void* to a function pointer without a cast; the sibling call sites (game-capture, window-helpers, obs-inject-library) already cast at the site. - obs-ffmpeg/texture-amf.cpp.hpp: C4459 caps x4 (rename the local to amf_caps, the file-static std::map stays), C4245 x2 (the AMF_SURFACE_USAGE / AMF_MEMORY_CPU_ACCESS bit-or arguments), C4100 x4 (UNUSED_PARAMETER on the unused param/encoder), C4189 x2 (a dead last_ts; convert_to_amf_ts is pure), C4244 x2 (the HDR nominal peak level into an amf_uint16, bounded at 10000). --- plugins/obs-ffmpeg/texture-amf.cpp.hpp | 61 +++++++++++-------- .../inject-helper/inject-helper.c.h | 3 +- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/plugins/obs-ffmpeg/texture-amf.cpp.hpp b/plugins/obs-ffmpeg/texture-amf.cpp.hpp index c3e8c3b3ff..2faaf3c4cf 100644 --- a/plugins/obs-ffmpeg/texture-amf.cpp.hpp +++ b/plugins/obs-ffmpeg/texture-amf.cpp.hpp @@ -467,13 +467,13 @@ static inline int get_preset(amf_base *enc, const char *preset) static inline void refresh_throughput_caps(amf_base *enc, const char *&preset) { AMF_RESULT res = AMF_OK; - AMFCapsPtr caps; + AMFCapsPtr amf_caps; set_opt(QUALITY_PRESET, get_preset(enc, preset)); - res = enc->amf_encoder->GetCaps(&caps); + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(get_opt_name(CAP_MAX_THROUGHPUT), &enc->max_throughput); - caps->GetProperty(get_opt_name(CAP_REQUESTED_THROUGHPUT), &enc->requested_throughput); + amf_caps->GetProperty(get_opt_name(CAP_MAX_THROUGHPUT), &enc->max_throughput); + amf_caps->GetProperty(get_opt_name(CAP_REQUESTED_THROUGHPUT), &enc->requested_throughput); } } @@ -653,6 +653,8 @@ static void roi_cb(void *param, obs_encoder_roi *roi) static void create_roi(amf_base *enc, AMFSurface *amf_surf) { + UNUSED_PARAMETER(amf_surf); + uint32_t mb_size = 16; /* H.264 is always 16x16 */ if (enc->codec == amf_codec_type::HEVC || enc->codec == amf_codec_type::AV1) { mb_size = 64; /* AMF HEVC & AV1 use 64x64 blocks */ @@ -663,9 +665,10 @@ static void create_roi(amf_base *enc, AMFSurface *amf_surf) if (!enc->roi_map) { AMFContext1Ptr context1(enc->amf_context); - AMF_RESULT res = context1->AllocSurfaceEx(AMF_MEMORY_HOST, AMF_SURFACE_GRAY32, mb_width, mb_height, - AMF_SURFACE_USAGE_DEFAULT | AMF_SURFACE_USAGE_LINEAR, - AMF_MEMORY_CPU_DEFAULT, &enc->roi_map); + AMF_RESULT res = context1->AllocSurfaceEx( + AMF_MEMORY_HOST, AMF_SURFACE_GRAY32, mb_width, mb_height, + (AMF_SURFACE_USAGE)(AMF_SURFACE_USAGE_DEFAULT | AMF_SURFACE_USAGE_LINEAR), + (AMF_MEMORY_CPU_ACCESS)(AMF_MEMORY_CPU_DEFAULT), &enc->roi_map); if (res != AMF_OK) { warn("Failed allocating surface for ROI map!"); @@ -832,7 +835,6 @@ try { throw amf_error("CreateSurfaceFromDX11Native failed", res); } - int64_t last_ts = convert_to_amf_ts(enc, pts - 1); int64_t cur_ts = convert_to_amf_ts(enc, pts); amf_surf->SetPts(cur_ts); @@ -937,7 +939,6 @@ try { throw amf_error("CreateSurfaceFromHostNative failed", res); } - int64_t last_ts = convert_to_amf_ts(enc, frame->pts - 1); int64_t cur_ts = convert_to_amf_ts(enc, frame->pts); amf_surf->SetPts(cur_ts); @@ -1308,6 +1309,8 @@ static const char *amf_avc_get_name(void *) static inline int get_avc_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "quality") == 0) { return AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY; } else if (astrcmpi(preset, "speed") == 0) { @@ -1649,13 +1652,13 @@ static void amf_avc_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_BFRAMES, &enc->bframes_supported); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_ROI, &enc->roi_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_BFRAMES, &enc->bframes_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_ROI, &enc->roi_supported); } const char *preset = obs_data_get_string(settings, "preset"); @@ -1808,6 +1811,8 @@ static const char *amf_hevc_get_name(void *) static inline int get_hevc_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "balanced") == 0) { return AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED; } else if (astrcmpi(preset, "speed") == 0) { @@ -2040,12 +2045,12 @@ static void amf_hevc_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_ROI, &enc->roi_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_ROI, &enc->roi_supported); } const bool is10bit = enc->amf_format == AMF_SURFACE_P010; @@ -2084,8 +2089,8 @@ static void amf_hevc_create_internal(amf_base *enc, obs_data_t *settings) md->whitePoint[1] = amf_hdr_primary(329, 1000); md->minMasteringLuminance = 0; md->maxMasteringLuminance = amf_make_lum(hdr_nominal_peak_level); - md->maxContentLightLevel = hdr_nominal_peak_level; - md->maxFrameAverageLightLevel = hdr_nominal_peak_level; + md->maxContentLightLevel = (amf_uint16)hdr_nominal_peak_level; + md->maxFrameAverageLightLevel = (amf_uint16)hdr_nominal_peak_level; set_hevc_property(enc, INPUT_HDR_METADATA, buf); } @@ -2219,6 +2224,8 @@ static const char *amf_av1_get_name(void *) static inline int get_av1_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "highquality") == 0) { return AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY; } else if (astrcmpi(preset, "quality") == 0) { @@ -2467,12 +2474,12 @@ static void amf_av1_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - AMF_RESULT res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + AMF_RESULT res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_BFRAMES, &enc->bframes_supported); - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_BFRAMES, &enc->bframes_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); /* For some reason there's no specific CAP for AV1, but should always be supported */ enc->roi_supported = true; } diff --git a/plugins/win-capture/inject-helper/inject-helper.c.h b/plugins/win-capture/inject-helper/inject-helper.c.h index fafc67d817..eedd004e49 100644 --- a/plugins/win-capture/inject-helper/inject-helper.c.h +++ b/plugins/win-capture/inject-helper/inject-helper.c.h @@ -29,7 +29,8 @@ static void load_debug_privilege(void) static inline HANDLE open_process(DWORD desired_access, bool inherit_handle, DWORD process_id) { HANDLE(WINAPI * open_process_proc)(DWORD, BOOL, DWORD); - open_process_proc = ms_get_obfuscated_func(GetModuleHandleW(L"KERNEL32"), "HxjcQrmkb|~", 0xc82efdf78201df87); + open_process_proc = (HANDLE(WINAPI *)(DWORD, BOOL, DWORD))ms_get_obfuscated_func( + GetModuleHandleW(L"KERNEL32"), "HxjcQrmkb|~", 0xc82efdf78201df87); return open_process_proc(desired_access, inherit_handle, process_id); } From 00fbdc3bcbd5a1d3579408d86200b44979a91c51 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:19:49 -0700 Subject: [PATCH 31/63] fix(msvc): clear the wave 9 first-party /W4 findings (#2626) From the x64 app-lane log of run 40633515355: - obs-ffmpeg/texture-amf.cpp.hpp:559 C4701/C4703: get_output_type is only assigned in the three codec arms of the switch; initialize it to NULL so an unknown codec reaches GetProperty() and the existing throw instead of an uninitialized read. - obs-outputs/rtmp-windows.c.h:8 C4245: libobs's sb_socket is a SOCKET, so the reset is INVALID_SOCKET rather than a plain -1. - obs-outputs/rtmp-windows.c.h:92 C4100: ideal_send_backlog_event never touched its can_write out-parameter; the parameter and its only argument are dropped. - shared/obs-inject-library/inject-library-windows.c.h:46 C4057: written_size is handed to a SIZE_T * by write_process_memory_t; declare it SIZE_T. --- plugins/obs-ffmpeg/texture-amf.cpp.hpp | 2 +- plugins/obs-outputs/rtmp-windows.c.h | 6 +++--- shared/obs-inject-library/inject-library-windows.c.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/obs-ffmpeg/texture-amf.cpp.hpp b/plugins/obs-ffmpeg/texture-amf.cpp.hpp index 2faaf3c4cf..00d36becd7 100644 --- a/plugins/obs-ffmpeg/texture-amf.cpp.hpp +++ b/plugins/obs-ffmpeg/texture-amf.cpp.hpp @@ -542,7 +542,7 @@ static void convert_to_encoder_packet(amf_base *enc, AMFDataPtr &data, encoder_p enc->packet_data = AMFBufferPtr(data); data->GetProperty(L"PTS", &packet->pts); - const wchar_t *get_output_type; + const wchar_t *get_output_type = NULL; switch (enc->codec) { case amf_codec_type::AVC: get_output_type = AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE; diff --git a/plugins/obs-outputs/rtmp-windows.c.h b/plugins/obs-outputs/rtmp-windows.c.h index 90a1213f9c..4590e8b342 100644 --- a/plugins/obs-outputs/rtmp-windows.c.h +++ b/plugins/obs-outputs/rtmp-windows.c.h @@ -5,7 +5,7 @@ static void fatal_sock_shutdown(struct rtmp_stream *stream) { closesocket(stream->rtmp.m_sb.sb_socket); - stream->rtmp.m_sb.sb_socket = -1; + stream->rtmp.m_sb.sb_socket = INVALID_SOCKET; stream->write_buf_len = 0; os_event_signal(stream->buffer_space_available_event); } @@ -107,7 +107,7 @@ static bool socket_event(struct rtmp_stream *stream, bool *can_write, uint64_t l return true; } -static void ideal_send_backlog_event(struct rtmp_stream *stream, bool *can_write) +static void ideal_send_backlog_event(struct rtmp_stream *stream) { ULONG ideal_send_backlog; int ret; @@ -304,7 +304,7 @@ static inline void socket_thread_windows_internal(struct rtmp_stream *stream) } else if (status == WAIT_OBJECT_0 + 2) { /* Ideal send backlog event */ - ideal_send_backlog_event(stream, &can_write); + ideal_send_backlog_event(stream); ResetEvent(send_backlog_event); idealsendbacklognotify(stream->rtmp.m_sb.sb_socket, &send_backlog_overlapped, NULL); diff --git a/shared/obs-inject-library/inject-library-windows.c.h b/shared/obs-inject-library/inject-library-windows.c.h index ee75a36885..ffcbd9c422 100644 --- a/shared/obs-inject-library/inject-library-windows.c.h +++ b/shared/obs-inject-library/inject-library-windows.c.h @@ -14,7 +14,7 @@ int inject_library_obf(HANDLE process, const wchar_t *dll, const char *create_re int ret = INJECT_ERROR_UNLIKELY_FAIL; DWORD last_error = 0; bool success = false; - size_t written_size; + SIZE_T written_size; DWORD thread_id; HANDLE thread = NULL; size_t size; From fbd3fe27ad96ce9ab68356655aaaa6db3d6dfb27 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:24:07 -0700 Subject: [PATCH 32/63] test(msvc): pin the submodule pointers that carry the wave 9 /W4 renames (#2626) obs-rust/obs-browser#16 (browser-client's shadowing `name` and `channels` locals) and obs-rust/obs-websocket#25 (Json.cpp's structured binding hiding the `key` parameter) are merged; both pointers must reach those commits. --- ci/test_browser_submodule.py | 20 ++++++++++++++------ ci/test_websocket_submodule.py | 6 ++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ci/test_browser_submodule.py b/ci/test_browser_submodule.py index 54f1741661..75420cd4de 100644 --- a/ci/test_browser_submodule.py +++ b/ci/test_browser_submodule.py @@ -21,6 +21,9 @@ # obs-rust/obs-browser#15: rename the browser-app locals that hide a parameter # and a local (C4457 `frame`, C4456 `args`) for obs-studio#2626. WARNING_SHADOWING_FIX = "b9c5db137711717bc02cdd265801ad26f270bd66" +# obs-rust/obs-browser#16: rename browser-client.cpp's shadowing `name` (C4456) and +# `channels` (C4458) locals, found in the same app-lane build. +WARNING_SHADOWING_FIX_CLIENT = "96e724b2c948c8500a263320520f971f3f6565c2" def git(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess: @@ -28,18 +31,18 @@ def git(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess: class BrowserSubmoduleTest(unittest.TestCase): - def test_pointer_keeps_the_warning_renames(self) -> None: + def _assert_pointer_at_least(self, commit: str, what: str) -> None: tree = git("ls-tree", "HEAD", SUBMODULE).stdout.split() self.assertEqual(tree[:2], ["160000", "commit"], f"{SUBMODULE} is not a submodule") pointer = tree[2] - if pointer == WARNING_SHADOWING_FIX: + if pointer == commit: return sub = ROOT / SUBMODULE if not (sub / ".git").exists(): self.skipTest(f"{SUBMODULE} is not checked out; cannot check ancestry of {pointer}") - has = git("merge-base", "--is-ancestor", WARNING_SHADOWING_FIX, pointer, cwd=sub) + has = git("merge-base", "--is-ancestor", commit, pointer, cwd=sub) if has.returncode != 0: - known = git("cat-file", "-e", f"{WARNING_SHADOWING_FIX}^{{commit}}", cwd=sub).returncode == 0 + known = git("cat-file", "-e", f"{commit}^{{commit}}", cwd=sub).returncode == 0 shallow = git("rev-parse", "--is-shallow-repository", cwd=sub).stdout.strip() == "true" if not known and shallow: # A shallow checkout may stop above the fix, so a miss here proves nothing. @@ -47,10 +50,15 @@ def test_pointer_keeps_the_warning_renames(self) -> None: self.assertEqual( has.returncode, 0, - f"{SUBMODULE} points at {pointer[:9]}, which lacks the /W4 shadowing renames " - f"({WARNING_SHADOWING_FIX[:9]})", + f"{SUBMODULE} points at {pointer[:9]}, which lacks {what} ({commit[:9]})", ) + def test_pointer_keeps_the_browser_app_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX, "the browser-app shadowing renames (#15)") + + def test_pointer_keeps_the_browser_client_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX_CLIENT, "the browser-client shadowing renames (#16)") + if __name__ == "__main__": unittest.main() diff --git a/ci/test_websocket_submodule.py b/ci/test_websocket_submodule.py index 3bdcd87483..4bef441eb7 100644 --- a/ci/test_websocket_submodule.py +++ b/ci/test_websocket_submodule.py @@ -24,6 +24,9 @@ # obs-rust/obs-websocket#24: rename the two inner errorCode locals in onMessage # (C4456) for the MSVC /W4 ratchet (obs-studio#2626), which the app build reports. WARNING_SHADOWING_FIX = "960b99e702f116f9cc80ff6b2d3741dc917b7d87" +# obs-rust/obs-websocket#25: the structured binding in Json.cpp's +# obs_data_set_json_array hides the function's own `key` parameter (C4457). +WARNING_JSON_BINDING_FIX = "c2366e8d2c212be569a4fce6687d8a3fb7c6be70" # Upstream commits without the fix that stale checkouts have committed (#492, #496). KNOWN_BAD = {"073a294cd0646fa1744b0ebf3293bfa63a869b50"} @@ -65,6 +68,9 @@ def test_pointer_keeps_the_bounded_session_drain(self): def test_pointer_keeps_the_warning_renames(self): self._assert_pointer_at_least(WARNING_SHADOWING_FIX, "the /W4 shadowing renames (#24)") + def test_pointer_keeps_the_json_binding_rename(self): + self._assert_pointer_at_least(WARNING_JSON_BINDING_FIX, "the Json.cpp binding rename (#25)") + class SessionDrainShapeTest(unittest.TestCase): """Stop() must read the drain predicate under the session mutex and bound the wait.""" From f6b484b5192bb1f52c5bf97fb071e7f5457a26c6 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:24:09 -0700 Subject: [PATCH 33/63] build(msvc): bump the submodules to the wave 9 /W4 renames (#2626) --- plugins/obs-browser | 2 +- plugins/obs-websocket | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/obs-browser b/plugins/obs-browser index b9c5db1377..96e724b2c9 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit b9c5db137711717bc02cdd265801ad26f270bd66 +Subproject commit 96e724b2c948c8500a263320520f971f3f6565c2 diff --git a/plugins/obs-websocket b/plugins/obs-websocket index 960b99e702..c2366e8d2c 160000 --- a/plugins/obs-websocket +++ b/plugins/obs-websocket @@ -1 +1 @@ -Subproject commit 960b99e702f116f9cc80ff6b2d3741dc917b7d87 +Subproject commit c2366e8d2c212be569a4fce6687d8a3fb7c6be70 From 06e3aa64890c17f0842f7bb5d65581e8e0297aa3 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:46:57 -0700 Subject: [PATCH 34/63] fix(msvc): clear the wave 10 win-capture C4457 findings (#2626) game-capture.c.h:1764 and window-capture.c.h:596,617,682,726,764 each declare a calldata_t local named data inside a callback that already has a data parameter. Renamed the locals to cd (the name upstream OBS uses for the same pattern); every use in the block follows. --- plugins/win-capture/game-capture.c.h | 14 +++---- plugins/win-capture/window-capture.c.h | 52 +++++++++++++------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/plugins/win-capture/game-capture.c.h b/plugins/win-capture/game-capture.c.h index 26815e6ac8..eb22cd2640 100644 --- a/plugins/win-capture/game-capture.c.h +++ b/plugins/win-capture/game-capture.c.h @@ -1761,15 +1761,15 @@ static void game_capture_tick(void *data, float seconds) ms_get_window_class(&gc->class, gc->window); } signal_handler_t *sh = obs_source_get_signal_handler(gc->source); - calldata_t data = {0}; + calldata_t cd = {0}; - calldata_set_ptr(&data, "source", gc->source); - calldata_set_string(&data, "title", gc->title.array); - calldata_set_string(&data, "class", gc->class.array); - calldata_set_string(&data, "executable", gc->executable.array); + calldata_set_ptr(&cd, "source", gc->source); + calldata_set_string(&cd, "title", gc->title.array); + calldata_set_string(&cd, "class", gc->class.array); + calldata_set_string(&cd, "executable", gc->executable.array); - signal_handler_signal(sh, "hooked", &data); - calldata_free(&data); + signal_handler_signal(sh, "hooked", &cd); + calldata_free(&cd); if (gc->audio_source) { reconfigure_audio_source(gc->audio_source, gc->window); diff --git a/plugins/win-capture/window-capture.c.h b/plugins/win-capture/window-capture.c.h index 61d63f3066..f74631ce58 100644 --- a/plugins/win-capture/window-capture.c.h +++ b/plugins/win-capture/window-capture.c.h @@ -593,10 +593,10 @@ static void wc_hide(void *data) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } } @@ -614,10 +614,10 @@ static void wc_tick(void *data, float seconds) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } if (!wc->title && !wc->class) { @@ -679,10 +679,10 @@ static void wc_tick(void *data, float seconds) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } return; } @@ -723,7 +723,7 @@ static void wc_tick(void *data, float seconds) wc->hooked = true; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; + calldata_t cd = {0}; struct dstr title = {0}; struct dstr class = {0}; struct dstr executable = {0}; @@ -732,16 +732,16 @@ static void wc_tick(void *data, float seconds) ms_get_window_class(&class, wc->window); ms_get_window_exe(&executable, wc->window); - calldata_set_ptr(&data, "source", wc->source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", class.array); - calldata_set_string(&data, "executable", executable.array); - signal_handler_signal(sh, "hooked", &data); + calldata_set_ptr(&cd, "source", wc->source); + calldata_set_string(&cd, "title", title.array); + calldata_set_string(&cd, "class", class.array); + calldata_set_string(&cd, "executable", executable.array); + signal_handler_signal(sh, "hooked", &cd); dstr_free(&title); dstr_free(&class); dstr_free(&executable); - calldata_free(&data); + calldata_free(&cd); } } @@ -761,7 +761,7 @@ static void wc_tick(void *data, float seconds) wc->hooked = true; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; + calldata_t cd = {0}; struct dstr title = {0}; struct dstr class = {0}; struct dstr executable = {0}; @@ -770,16 +770,16 @@ static void wc_tick(void *data, float seconds) ms_get_window_class(&class, wc->window); ms_get_window_exe(&executable, wc->window); - calldata_set_ptr(&data, "source", wc->source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", class.array); - calldata_set_string(&data, "executable", executable.array); - signal_handler_signal(sh, "hooked", &data); + calldata_set_ptr(&cd, "source", wc->source); + calldata_set_string(&cd, "title", title.array); + calldata_set_string(&cd, "class", class.array); + calldata_set_string(&cd, "executable", executable.array); + signal_handler_signal(sh, "hooked", &cd); dstr_free(&title); dstr_free(&class); dstr_free(&executable); - calldata_free(&data); + calldata_free(&cd); } } } From c4e0e6332e6c1e3900310c7702f82f29bcf00621 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:46:57 -0700 Subject: [PATCH 35/63] test(msvc): pin the obs-browser pointer at the panel renames (#2626) --- ci/test_browser_submodule.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/test_browser_submodule.py b/ci/test_browser_submodule.py index 75420cd4de..8e58863215 100644 --- a/ci/test_browser_submodule.py +++ b/ci/test_browser_submodule.py @@ -24,6 +24,9 @@ # obs-rust/obs-browser#16: rename browser-client.cpp's shadowing `name` (C4456) and # `channels` (C4458) locals, found in the same app-lane build. WARNING_SHADOWING_FIX_CLIENT = "96e724b2c948c8500a263320520f971f3f6565c2" +# obs-rust/obs-browser#17: rename the panel locals that hide a class member +# (C4458 `script` in browser-panel-client.cpp, `url` in browser-panel.cpp). +WARNING_SHADOWING_FIX_PANEL = "463e16b468ba607dfea2cc8bfcc1a0204b441ed3" def git(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess: @@ -59,6 +62,9 @@ def test_pointer_keeps_the_browser_app_renames(self) -> None: def test_pointer_keeps_the_browser_client_renames(self) -> None: self._assert_pointer_at_least(WARNING_SHADOWING_FIX_CLIENT, "the browser-client shadowing renames (#16)") + def test_pointer_keeps_the_panel_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX_PANEL, "the panel shadowing renames (#17)") + if __name__ == "__main__": unittest.main() From c5d5fea93eb36023dde0cb2c2ae324700933a96e Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Tue, 27 Oct 2026 22:46:58 -0700 Subject: [PATCH 36/63] build(msvc): bump obs-browser to the panel renames (#2626) --- plugins/obs-browser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/obs-browser b/plugins/obs-browser index 96e724b2c9..463e16b468 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit 96e724b2c948c8500a263320520f971f3f6565c2 +Subproject commit 463e16b468ba607dfea2cc8bfcc1a0204b441ed3 From 575be38a8808446c1d72be310e65e65089c4d4db Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 11:20:50 -0700 Subject: [PATCH 37/63] build(msvc): exempt the /W4 findings left in the vendored deps (#2626) The first Windows app-lane build at /W4 (release-rust.yaml verify_only on fix/2626-msvc-w4, run 40709658465) failed in both the x64 and the arm64 build with C2220, from four warnings that are all in vendored code: plugins/obs-outputs/librtmp/rtmp.c C4245 int -> SOCKET / uint8_t C4456 shadowed loop counter `i` C4706 `while ((s = ...))` condition deps/libdshowcapture/src/source/device.cpp:483 C4456 shadowed `defaultMT` librtmp already carries per-source suppressions for the clang/gcc classes (#516, #2623); this adds the MSVC ones to the same source property, scoped to COMPILE_LANG_AND_ID:C,MSVC. libdshowcapture is a vendored submodule whose sources are compiled into its consumers (win-dshow, obs-virtualcam-module) through an INTERFACE target that already carries /wd4005 and /wd4018, so the C4456 exemption joins that line, scoped to CXX+MSVC. ci/test_msvc_warning_level.py pins both exemptions. Every other target built at /W4 in that run -- libobs, frontend, obs-ffmpeg, obs-nvenc, obs-qsv11, win-capture, the graphics hook, shared/ -- so this is the last class the Windows lane reports. --- ci/test_msvc_warning_level.py | 26 ++++++++++++++++++++++++++ deps/libdshowcapture/CMakeLists.txt | 8 +++++++- plugins/obs-outputs/CMakeLists.txt | 7 +++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 1e036b47ec..b91a91d83f 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -124,5 +124,31 @@ def test_each_product_cxx_target_opts_in(self) -> None: self.assertEqual(missing, []) +OUTPUTS = ROOT / "plugins" / "obs-outputs" / "CMakeLists.txt" +DSHOW = ROOT / "deps" / "libdshowcapture" / "CMakeLists.txt" + + +class MsvcVendoredDependencyExemptionTest(unittest.TestCase): + """The /W4-only findings left in vendored code are suppressed, not edited (#516).""" + + def test_librtmp_exempts_its_w4_only_classes_on_msvc(self) -> None: + text = OUTPUTS.read_text(encoding="utf-8") + block = text.split("set_source_files_properties(", 1)[1].split("\n)", 1)[0] + self.assertIn("librtmp/rtmp.c", block) + self.assertRegex( + block, + r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4245;/wd4456;/wd4706>", + "librtmp needs C4245, C4456 and C4706 at /W4, scoped to the C language", + ) + + def test_libdshowcapture_exempts_its_shadowed_local_on_msvc_cxx(self) -> None: + text = DSHOW.read_text(encoding="utf-8") + self.assertRegex( + text, + r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4456\b", + "src/source/device.cpp:483 is vendored; C4456 stays suppressed", + ) + + if __name__ == "__main__": unittest.main() diff --git a/deps/libdshowcapture/CMakeLists.txt b/deps/libdshowcapture/CMakeLists.txt index 2e04053129..90438869e6 100644 --- a/deps/libdshowcapture/CMakeLists.txt +++ b/deps/libdshowcapture/CMakeLists.txt @@ -40,4 +40,10 @@ target_include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/src/external/capture-device-support/Library") target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) -target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018) + +# /wd4005 and /wd4018 are the vendored-code suppressions this library has always +# carried. The MSVC /W4-only C4456 below belongs to the same exempt set (#2626, +# #516): src/source/device.cpp:483 shadows its `defaultMT` local. Fixing it +# would mean editing the vendored submodule, so the warning is suppressed for +# the consumers that compile these sources (win-dshow, obs-virtualcam-module). +target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018 $<$:/wd4456>) diff --git a/plugins/obs-outputs/CMakeLists.txt b/plugins/obs-outputs/CMakeLists.txt index 36d28e381f..6dcea8a70e 100644 --- a/plugins/obs-outputs/CMakeLists.txt +++ b/plugins/obs-outputs/CMakeLists.txt @@ -98,7 +98,10 @@ target_include_directories( # Vendored librtmp (C89 code that casts away const throughout) is not ported # or edited here; -Wcast-qual, -Wshadow and -Wpedantic (its __FUNCTION__ use; -# obs-rust/obs-studio#516, #2623) cover our own sources. +# obs-rust/obs-studio#516, #2623) cover our own sources. The same exemption +# covers the MSVC /W4-only classes librtmp trips (#2626): C4245 an int stored +# in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, and C4706 its +# `while ((s = ...))` assignment conditions. set_source_files_properties( librtmp/amf.c librtmp/cencode.c @@ -109,7 +112,7 @@ set_source_files_properties( librtmp/rtmp.c PROPERTIES COMPILE_OPTIONS - "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>" + "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4245;/wd4456;/wd4706>" ) target_compile_options( From ceaacedf64e3724ee3375b4636f814a070216cee Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 11:59:27 -0700 Subject: [PATCH 38/63] build(msvc): clear the wave 11 /W4 findings in the vendored trees (#2626) The app-lane run at 312015afd (release-rust.yaml verify_only, run 40744279457) confirms the first two exemptions work -- librtmp no longer reports C4245/C4456/C4706 and device.cpp no longer reports C4456, so per-source COMPILE_OPTIONS do reach cl.exe through the Visual Studio generator. It then stopped on the next class per translation unit: plugins/obs-outputs/librtmp/{rtmp,amf}.c C4702 unreachable code deps/libdshowcapture/src/source/encoder.cpp C4458 `config` deps/libdshowcapture/src/source/output-filter.cpp C4458 `pin` Those are vendored, so they join the exemptions already in place: /wd4702 for librtmp, /wd4458 for libdshowcapture. ci/test_msvc_warning_level.py pins both extended lists. The same run also reported C4701 `err_code` in plugins/obs-outputs/ rtmp-windows.c.h, which is first-party. master's #2220 socket-loop rewrite (the code this branch now sits on) already initializes both leaves, so no change is needed here. --- ci/test_msvc_warning_level.py | 10 +++++----- deps/libdshowcapture/CMakeLists.txt | 15 ++++++++++----- plugins/obs-outputs/CMakeLists.txt | 9 ++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index b91a91d83f..5fef8dbf0e 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -137,16 +137,16 @@ def test_librtmp_exempts_its_w4_only_classes_on_msvc(self) -> None: self.assertIn("librtmp/rtmp.c", block) self.assertRegex( block, - r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4245;/wd4456;/wd4706>", - "librtmp needs C4245, C4456 and C4706 at /W4, scoped to the C language", + r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4245;/wd4456;/wd4702;/wd4706>", + "librtmp needs C4245, C4456, C4702 and C4706 at /W4, scoped to the C language", ) - def test_libdshowcapture_exempts_its_shadowed_local_on_msvc_cxx(self) -> None: + def test_libdshowcapture_exempts_its_shadowed_locals_on_msvc_cxx(self) -> None: text = DSHOW.read_text(encoding="utf-8") self.assertRegex( text, - r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4456\b", - "src/source/device.cpp:483 is vendored; C4456 stays suppressed", + r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4456;/wd4458>", + "device.cpp:483 and encoder.cpp/output-filter.cpp are vendored; C4456/C4458 stay suppressed", ) diff --git a/deps/libdshowcapture/CMakeLists.txt b/deps/libdshowcapture/CMakeLists.txt index 90438869e6..0d688d7f50 100644 --- a/deps/libdshowcapture/CMakeLists.txt +++ b/deps/libdshowcapture/CMakeLists.txt @@ -42,8 +42,13 @@ target_include_directories( target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) # /wd4005 and /wd4018 are the vendored-code suppressions this library has always -# carried. The MSVC /W4-only C4456 below belongs to the same exempt set (#2626, -# #516): src/source/device.cpp:483 shadows its `defaultMT` local. Fixing it -# would mean editing the vendored submodule, so the warning is suppressed for -# the consumers that compile these sources (win-dshow, obs-virtualcam-module). -target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018 $<$:/wd4456>) +# carried. The MSVC /W4-only C4456/C4458 below belong to the same exempt set +# (#2626, #516): src/source/device.cpp:483 shadows its `defaultMT` local, and +# src/source/encoder.cpp / output-filter.cpp shadow the class members `config` +# and `pin`. Fixing them would mean editing the vendored submodule, so the +# warnings are suppressed for the consumers that compile these sources +# (win-dshow, obs-virtualcam-module). +target_compile_options( + libdshowcapture + INTERFACE /wd4005 /wd4018 $<$:/wd4456;/wd4458> +) diff --git a/plugins/obs-outputs/CMakeLists.txt b/plugins/obs-outputs/CMakeLists.txt index 6dcea8a70e..9a87a155d7 100644 --- a/plugins/obs-outputs/CMakeLists.txt +++ b/plugins/obs-outputs/CMakeLists.txt @@ -100,8 +100,11 @@ target_include_directories( # or edited here; -Wcast-qual, -Wshadow and -Wpedantic (its __FUNCTION__ use; # obs-rust/obs-studio#516, #2623) cover our own sources. The same exemption # covers the MSVC /W4-only classes librtmp trips (#2626): C4245 an int stored -# in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, and C4706 its -# `while ((s = ...))` assignment conditions. +# in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, C4706 its +# `while ((s = ...))` assignment conditions, and C4702 the tail it leaves +# unreachable after its own error exits. These are per-source options: the +# Visual Studio generator does honour them, which the 2026-10-28 app-lane runs +# on this branch show (the C4245/C4456/C4706 findings stop being reported). set_source_files_properties( librtmp/amf.c librtmp/cencode.c @@ -112,7 +115,7 @@ set_source_files_properties( librtmp/rtmp.c PROPERTIES COMPILE_OPTIONS - "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4245;/wd4456;/wd4706>" + "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4245;/wd4456;/wd4702;/wd4706>" ) target_compile_options( From 376b99c7faf2ca521208471634dd515628bcf75e Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 12:23:49 -0700 Subject: [PATCH 39/63] fix(msvc): give the disabled module a provably-set declaration (#2626) The Windows app lane at /W4 reports, in libobs-objects.vcxproj: libobs/obs-module.c.h(528,1): warning C4701: potentially uninitialized local variable 'disabled_module' used libobs/obs-module.c.h(528,1): warning C4703: potentially uninitialized local pointer variable 'disabled_module' used C2220 turns both into errors. This is first-party libobs code, so it is fixed at the site rather than suppressed. `obs_module_load_rules_open_route()` only returns CORE_CONTINUES together with DISABLE (and `obs_module_load_rules_init_route()` only returns KEEP_TYPE together with DISABLE), so the dereference at :528 was safe by invariant -- but that invariant lives in another translation unit, and /W4 cannot see it. Move the two dereferences into the `DISABLE` branch that creates the module, so the assignment is dominated by the creation in the same scope. Behaviour is unchanged: the same route bits reach the same code, the comment names the invariant that makes the nesting exact. --- libobs/obs-module.c.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libobs/obs-module.c.h b/libobs/obs-module.c.h index 8c172b5933..7df732cf07 100644 --- a/libobs/obs-module.c.h +++ b/libobs/obs-module.c.h @@ -521,13 +521,18 @@ static void load_all_callback(void *param, const struct obs_module_info2 *info) blog(LOG_DEBUG, "Failed to load module file '%s', incompatible version", info->bin_path); break; } - if (route & OBS_MODULE_LOAD_RULES_DISABLE) + if (route & OBS_MODULE_LOAD_RULES_DISABLE) { obs_create_disabled_module(&disabled_module, info->bin_path, info->data_path, (enum obs_module_load_state)state); - if ((route & OBS_MODULE_LOAD_RULES_CORE_CONTINUES) && obs_module_load_rules_is_core(info->type)) { - disabled_module->module_type = info->type; - blog(LOG_WARNING, "Core module '%s' could not be opened, continuing without it", info->name); - return; + /* CORE_CONTINUES is only returned together with DISABLE + * (obs_module_load_rules_open_route()), so this is the module + * that carries the type. Keeping the two in one branch also + * shows the compiler the variable is set before its use. */ + if ((route & OBS_MODULE_LOAD_RULES_CORE_CONTINUES) && obs_module_load_rules_is_core(info->type)) { + disabled_module->module_type = info->type; + blog(LOG_WARNING, "Core module '%s' could not be opened, continuing without it", info->name); + return; + } } if (route & OBS_MODULE_LOAD_RULES_FAIL) goto load_failure; @@ -537,11 +542,14 @@ static void load_all_callback(void *param, const struct obs_module_info2 *info) route = obs_module_load_rules_init_route(obs_init_module(module), &state); if (route & OBS_MODULE_LOAD_RULES_FREE) free_module(module); - if (route & OBS_MODULE_LOAD_RULES_DISABLE) + if (route & OBS_MODULE_LOAD_RULES_DISABLE) { obs_create_disabled_module(&disabled_module, info->bin_path, info->data_path, (enum obs_module_load_state)state); - if (route & OBS_MODULE_LOAD_RULES_KEEP_TYPE) - disabled_module->module_type = info->type; + /* KEEP_TYPE likewise comes only with DISABLE + * (obs_module_load_rules_init_route()). */ + if (route & OBS_MODULE_LOAD_RULES_KEEP_TYPE) + disabled_module->module_type = info->type; + } if (route & OBS_MODULE_LOAD_RULES_SET_TYPE) module->module_type = info->type; From 5909af124b9ce986ecbfcccdc20539bf48013b9f Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 12:23:49 -0700 Subject: [PATCH 40/63] build(msvc): exempt ElgatoUVCDevice's C4244 at /W4 (#2626) The app-lane run 40750374851 (release-rust.yaml verify_only on 69b8f19b5) cleared every class the previous wave fixed and stopped on two new ones. One is first-party (`obs-module.c.h`, previous commit); the other is vendored: deps/libdshowcapture/src/external/capture-device-support/Library/ ElgatoUVCDevice.cpp(218,27): warning C4244: '+=': conversion from 'int' to 'uint8_t', possible loss of data That tree is a submodule this branch does not edit, so C4244 joins the CXX/MSVC list the INTERFACE target already carries (/wd4005 /wd4018 /wd4456 /wd4458). ci/test_msvc_warning_level.py pins the extended list, which is the RED/GREEN for the exemption. --- ci/test_msvc_warning_level.py | 5 +++-- deps/libdshowcapture/CMakeLists.txt | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 5fef8dbf0e..6b12750ad6 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -145,8 +145,9 @@ def test_libdshowcapture_exempts_its_shadowed_locals_on_msvc_cxx(self) -> None: text = DSHOW.read_text(encoding="utf-8") self.assertRegex( text, - r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4456;/wd4458>", - "device.cpp:483 and encoder.cpp/output-filter.cpp are vendored; C4456/C4458 stay suppressed", + r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4244;/wd4456;/wd4458>", + "device.cpp:483 and encoder.cpp/output-filter.cpp/ElgatoUVCDevice.cpp " + "are vendored; C4244/C4456/C4458 stay suppressed", ) diff --git a/deps/libdshowcapture/CMakeLists.txt b/deps/libdshowcapture/CMakeLists.txt index 0d688d7f50..bdda77d184 100644 --- a/deps/libdshowcapture/CMakeLists.txt +++ b/deps/libdshowcapture/CMakeLists.txt @@ -42,13 +42,14 @@ target_include_directories( target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) # /wd4005 and /wd4018 are the vendored-code suppressions this library has always -# carried. The MSVC /W4-only C4456/C4458 below belong to the same exempt set -# (#2626, #516): src/source/device.cpp:483 shadows its `defaultMT` local, and +# carried. The MSVC /W4-only C4244/C4456/C4458 below belong to the same exempt set +# (#2626, #516): src/source/device.cpp:483 shadows its `defaultMT` local, # src/source/encoder.cpp / output-filter.cpp shadow the class members `config` -# and `pin`. Fixing them would mean editing the vendored submodule, so the -# warnings are suppressed for the consumers that compile these sources -# (win-dshow, obs-virtualcam-module). +# and `pin`, and external/capture-device-support/Library/ElgatoUVCDevice.cpp:218 +# stores an int into a uint8_t. Fixing them would mean editing the vendored +# submodule, so the warnings are suppressed for the consumers that compile these +# sources (win-dshow, obs-virtualcam-module). target_compile_options( libdshowcapture - INTERFACE /wd4005 /wd4018 $<$:/wd4456;/wd4458> + INTERFACE /wd4005 /wd4018 $<$:/wd4244;/wd4456;/wd4458> ) From 01227c5371085903cbc062cfa0139293844f3924 Mon Sep 17 00:00:00 2001 From: zackees Date: Wed, 28 Oct 2026 12:54:39 -0700 Subject: [PATCH 41/63] build(msvc): exempt librtmp md5's C4244 and win-dshow's C4201 at /W4 (#2626) Wave 13 of the /W4 app-lane ratchet, from the x64/arm64 logs of the verify-only run on the previous head: - plugins/obs-outputs/librtmp/md5.c: 18x C4244 (`MD5_u32plus` -> `unsigned char` in the digest stores). Vendored C89, never edited here, so /wd4244 joins the existing per-source MSVC list for the librtmp sources. - plugins/win-dshow/win-dshow-encoder.cpp.hpp:17,18: C4201 nameless struct/union, i.e. the libobs header unions again. win-dshow was missing from the per-target C4201 exemption list; it now calls obs_msvc_exempt_c4201(), the shape #2626 decided on. ci/test_msvc_warning_level.py pins both (win-dshow joins C4201_TARGETS and the librtmp regex covers /wd4244). --- ci/test_msvc_warning_level.py | 5 +++-- plugins/obs-outputs/CMakeLists.txt | 11 ++++++----- plugins/win-dshow/CMakeLists.txt | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 6b12750ad6..3b1ee35216 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -70,6 +70,7 @@ def test_wx_comes_from_the_compile_time_setting(self) -> None: "obs-browser": "plugins/CMakeLists.txt", "obs-vst": "plugins/obs-vst/CMakeLists.txt", "obs-websocket": "plugins/CMakeLists.txt", + "win-dshow": "plugins/win-dshow/CMakeLists.txt", } @@ -137,8 +138,8 @@ def test_librtmp_exempts_its_w4_only_classes_on_msvc(self) -> None: self.assertIn("librtmp/rtmp.c", block) self.assertRegex( block, - r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4245;/wd4456;/wd4702;/wd4706>", - "librtmp needs C4245, C4456, C4702 and C4706 at /W4, scoped to the C language", + r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4244;/wd4245;/wd4456;/wd4702;/wd4706>", + "librtmp needs C4244, C4245, C4456, C4702 and C4706 at /W4, scoped to the C language", ) def test_libdshowcapture_exempts_its_shadowed_locals_on_msvc_cxx(self) -> None: diff --git a/plugins/obs-outputs/CMakeLists.txt b/plugins/obs-outputs/CMakeLists.txt index 9a87a155d7..7f11fd4da0 100644 --- a/plugins/obs-outputs/CMakeLists.txt +++ b/plugins/obs-outputs/CMakeLists.txt @@ -99,10 +99,11 @@ target_include_directories( # Vendored librtmp (C89 code that casts away const throughout) is not ported # or edited here; -Wcast-qual, -Wshadow and -Wpedantic (its __FUNCTION__ use; # obs-rust/obs-studio#516, #2623) cover our own sources. The same exemption -# covers the MSVC /W4-only classes librtmp trips (#2626): C4245 an int stored -# in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, C4706 its -# `while ((s = ...))` assignment conditions, and C4702 the tail it leaves -# unreachable after its own error exits. These are per-source options: the +# covers the MSVC /W4-only classes librtmp trips (#2626): C4244 the +# `MD5_u32plus` state shifted down into its `unsigned char` digest in md5.c, +# C4245 an int stored in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, +# C4706 its `while ((s = ...))` assignment conditions, and C4702 the tail it +# leaves unreachable after its own error exits. These are per-source options: the # Visual Studio generator does honour them, which the 2026-10-28 app-lane runs # on this branch show (the C4245/C4456/C4706 findings stop being reported). set_source_files_properties( @@ -115,7 +116,7 @@ set_source_files_properties( librtmp/rtmp.c PROPERTIES COMPILE_OPTIONS - "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4245;/wd4456;/wd4702;/wd4706>" + "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4244;/wd4245;/wd4456;/wd4702;/wd4706>" ) target_compile_options( diff --git a/plugins/win-dshow/CMakeLists.txt b/plugins/win-dshow/CMakeLists.txt index 8a947dd8c5..e1d75a81fd 100644 --- a/plugins/win-dshow/CMakeLists.txt +++ b/plugins/win-dshow/CMakeLists.txt @@ -5,6 +5,10 @@ find_package(FFmpeg 8.0 REQUIRED avcodec avutil) add_library(win-dshow MODULE) add_library(OBS::dshow ALIAS win-dshow) +# The C++ TUs including the libobs headers report the nameless unions C4201 at +# /W4; the same per-target exemption as the other product C++ targets (#2626). +obs_msvc_exempt_c4201(win-dshow) + if(NOT TARGET OBS::tiny-nv12-scale) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/obs-tiny-nv12-scale" obs-tiny-nv12-scale) endif() From 65caeac8841c401528d2febeb78bac4cef60d08d Mon Sep 17 00:00:00 2001 From: zackees Date: Wed, 28 Oct 2026 13:20:03 -0700 Subject: [PATCH 42/63] build(msvc): clear the wave 14 /W4 findings in the hardware test tools (#2626) From the x64 app-lane log of the verify-only run on the previous head: - plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h:744 C4701 `next_seek_position`: cl.exe cannot see that `want_seek` is only raised next to the assignment, across the chunk-flush branch, so the declaration carries the zero. - plugins/obs-qsv11/obs-qsv-test:171 C4189 `sts` and :183 C4456 `idx`, and plugins/obs-ffmpeg/obs-amf-test:154 C4456 `idx`: the MFX session status is not used (a failed session is null, handled below) and the adapter print loop's structured binding shadowed the probe's counter. - plugins/obs-nvenc/obs-nvenc-test:380 C4456 `res`: renamed to `preset_status`, the preset-config query is a different status from the caps query above it. Local: `./lint --fix` ok (65.5 s), `ci/test_msvc_warning_level.py` 12 tests OK. --- plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h | 5 ++++- plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp | 4 ++-- plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp | 8 ++++---- plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp | 8 +++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h index 8e55b8218b..457217bb10 100644 --- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h +++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h @@ -661,7 +661,10 @@ static void *ffmpeg_mux_io_thread(void *data) // ffmpeg, then we flush the chunk. next_seek_position is the actual // offset we should seek to when we write the chunk. uint64_t current_seek_position = 0; - uint64_t next_seek_position; + // want_seek is only raised next to the assignment below, so the read in + // the write path is always dominated by it; cl.exe cannot see that across + // the chunk-flush branch, so the declaration carries the zero (#2626). + uint64_t next_seek_position = 0; for (;;) { // Wait for ffmpeg to write data to the buffer diff --git a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp index 45cf3498fa..6ac9be7e3a 100644 --- a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp +++ b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp @@ -151,8 +151,8 @@ try { while (get_adapter_caps(factory, idx++)) ; - for (auto &[idx, caps] : adapter_info) { - printf("[%u]\n", idx); + for (auto &[adapter_index, caps] : adapter_info) { + printf("[%u]\n", adapter_index); printf("is_amd=%s\n", caps.is_amd ? "true" : "false"); printf("supports_avc=%s\n", caps.supports_avc ? "true" : "false"); printf("supports_hevc=%s\n", caps.supports_hevc ? "true" : "false"); diff --git a/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp b/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp index 2469848582..58ee84fca0 100644 --- a/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp +++ b/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp @@ -377,11 +377,11 @@ static bool get_adapter_caps(int adapter_idx, codec_caps_map &caps, device_info preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; - NVENCSTATUS res = nv.nvEncGetEncodePresetConfigEx(nvSession.ptr, *guid, NV_ENC_PRESET_P7_GUID, - NV_ENC_TUNING_INFO_ULTRA_HIGH_QUALITY, - &preset_config); + NVENCSTATUS preset_status = nv.nvEncGetEncodePresetConfigEx(nvSession.ptr, *guid, NV_ENC_PRESET_P7_GUID, + NV_ENC_TUNING_INFO_ULTRA_HIGH_QUALITY, + &preset_config); - device_info.caps[codec_name]["uhq"] = res == NV_ENC_SUCCESS ? 1 : 0; + device_info.caps[codec_name]["uhq"] = preset_status == NV_ENC_SUCCESS ? 1 : 0; caps[codec_name]["uhq"] = std::max(device_info.caps[codec_name]["uhq"], caps[codec_name]["uhq"]); #endif } diff --git a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp index 6c2b127d70..ef565dd3ad 100644 --- a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp +++ b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp @@ -168,7 +168,9 @@ try { MFXSetConfigFilterProperty(cfg, (const mfxU8 *)"mfxImplDescription.Impl", impl); mfxSession m_session = nullptr; - mfxStatus sts = MFXCreateSession(loader, 0, &m_session); + // A session that failed to open is simply null: the probe below then + // reports no adapters and the close is skipped, so the status is not used. + (void)MFXCreateSession(loader, 0, &m_session); uint32_t idx = 0; while (get_adapter_caps(factory, loader, m_session, idx++) == true) @@ -180,8 +182,8 @@ try { MFXUnload(loader); - for (auto &[idx, caps] : adapter_info) { - printf("[%u]\n", idx); + for (auto &[adapter_index, caps] : adapter_info) { + printf("[%u]\n", adapter_index); printf("is_intel=%s\n", caps.is_intel ? "true" : "false"); printf("is_dgpu=%s\n", caps.is_dgpu ? "true" : "false"); printf("supports_av1=%s\n", caps.supports_av1 ? "true" : "false"); From b7f6d9aa26455b57885ab6b5a7b5ff7c3a2c37db Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 13:26:57 -0700 Subject: [PATCH 43/63] build(msvc): exempt obs-browser's dead static at /W4 (#2626) The wave 14 x64 app-lane log also stopped on C4505 in the submodule: plugins/obs-browser/obs-browser-page/obs-browser-page-main.cpp(44,13): warning C4505: 'SetHighDPIv2Scaling': unreferenced function with internal linkage has been removed The function is dead in obs-browser, not in this tree, so the obs-browser-helper target opts into a new obs_msvc_exempt_c4505() helper beside the C4201 one (properties-view already carries the same per-target /wd4505). Deleting the function stays an obs-rust/obs-browser change; ci/test_msvc_warning_level.py pins the helper, its no-op guard, the single opt-in and the absence of a blanket /wd4505 in the MSVC config. Local: ci/test_msvc_warning_level.py 15 tests OK, ./lint ok (57.6 s). Refs #2626 --- ci/test_msvc_warning_level.py | 33 +++++++++++++++++++++++++++++++ cmake/common/helpers_common.cmake | 15 ++++++++++++++ plugins/CMakeLists.txt | 2 ++ 3 files changed, 50 insertions(+) diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py index 3b1ee35216..6dbb00892a 100644 --- a/ci/test_msvc_warning_level.py +++ b/ci/test_msvc_warning_level.py @@ -125,6 +125,39 @@ def test_each_product_cxx_target_opts_in(self) -> None: self.assertEqual(missing, []) +class MsvcDeadInternalFunctionExemptionTest(unittest.TestCase): + """C4505 is exempted only for the obs-browser helper target (#2626).""" + + def helper(self) -> str: + text = HELPERS.read_text(encoding="utf-8") + self.assertIn("function(obs_msvc_exempt_c4505 target)", text) + return text.split("function(obs_msvc_exempt_c4505 target)", 1)[1].split("endfunction()", 1)[0] + + def test_helper_is_cxx_and_msvc_scoped(self) -> None: + helper = self.helper() + self.assertIn("/wd4505", helper) + self.assertIn("COMPILE_LANG_AND_ID:CXX,MSVC", helper) + + def test_helper_is_a_no_op_when_the_module_is_disabled(self) -> None: + helper = self.helper() + guard = helper.find("if(NOT TARGET ${target})") + self.assertNotEqual(guard, -1, "the helper must tolerate a target the config did not create") + self.assertLess(guard, helper.find("target_compile_options"), "return before touching the target") + + def test_only_the_obs_browser_helper_opts_in(self) -> None: + # The dead static is `SetHighDPIv2Scaling()` in the obs-browser + # submodule, so the exemption belongs to that target and nowhere else; + # deleting the function is an obs-rust/obs-browser change. + body = (ROOT / "plugins" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertIn("obs_msvc_exempt_c4505(obs-browser-helper)", body) + self.assertEqual(body.count("obs_msvc_exempt_c4505("), 1) + windows = WINDOWS.read_text(encoding="utf-8") + self.assertIsNone( + re.search(r"(?:/wd4201>) endfunction() +# obs_msvc_exempt_c4505: Disable C4505 on one C++ target (MSVC /W4, #2626) +# +# /W4 reports C4505 "unreferenced function with internal linkage has been +# removed" for the static SetHighDPIv2Scaling() in the obs-browser submodule's +# obs-browser-page-main.cpp. That function is dead in obs-browser, not in this +# tree: deleting it belongs to an obs-rust/obs-browser change, so until that +# lands the target gets the same per-target exemption properties-view already +# uses, and never a blanket /wd4505 for every C++ target. +function(obs_msvc_exempt_c4505 target) + if(NOT TARGET ${target}) + return() + endif() + target_compile_options(${target} PRIVATE $<$:/wd4505>) +endfunction() + # _handle_generator_expression_dependency: Helper function to yield dependency from a generator expression function(_handle_generator_expression_dependency library) set(oneValueArgs FOUND_VAR) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 0831917064..6bcba36c79 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -27,6 +27,8 @@ macro(check_obs_browser) # defined by the submodule's own CMakeLists, so the exemption is applied # here (#2626). obs_msvc_exempt_c4201(obs-browser) + # obs-browser-page-main.cpp's dead static function, C4505 (#2626). + obs_msvc_exempt_c4505(obs-browser-helper) endif() else() add_custom_target(obs-browser) From e12f74d2ff138bb459e5ac0e7e1fea41f40654d3 Mon Sep 17 00:00:00 2001 From: zackees Date: Wed, 28 Oct 2026 13:33:14 -0700 Subject: [PATCH 44/63] build(msvc): name the adapter print binding after the caps, not the adapter (#2626) Wave 15: `adapter_index` hides a *global* of that name from a VPL header in the qsv-test unity TU (C4459), the wave-14 rename having only avoided the function-local `idx`. `caps_index` names what the binding actually iterates (adapter_info's caps map) and collides with nothing; the amf-test twin gets the same name so the two tools stay identical. Refs #2626 --- plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp | 4 ++-- plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp index 6ac9be7e3a..0e2a6d1422 100644 --- a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp +++ b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp @@ -151,8 +151,8 @@ try { while (get_adapter_caps(factory, idx++)) ; - for (auto &[adapter_index, caps] : adapter_info) { - printf("[%u]\n", adapter_index); + for (auto &[caps_index, caps] : adapter_info) { + printf("[%u]\n", caps_index); printf("is_amd=%s\n", caps.is_amd ? "true" : "false"); printf("supports_avc=%s\n", caps.supports_avc ? "true" : "false"); printf("supports_hevc=%s\n", caps.supports_hevc ? "true" : "false"); diff --git a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp index ef565dd3ad..2daa26fa6c 100644 --- a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp +++ b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp @@ -182,8 +182,8 @@ try { MFXUnload(loader); - for (auto &[adapter_index, caps] : adapter_info) { - printf("[%u]\n", adapter_index); + for (auto &[caps_index, caps] : adapter_info) { + printf("[%u]\n", caps_index); printf("is_intel=%s\n", caps.is_intel ? "true" : "false"); printf("is_dgpu=%s\n", caps.is_dgpu ? "true" : "false"); printf("supports_av1=%s\n", caps.supports_av1 ? "true" : "false"); From 9349045d40410e093a2a52dd93e58dd247788382 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 14:24:15 -0700 Subject: [PATCH 45/63] build(msvc): clear the wave 16 /W4 findings in the Qt frontend (#2626) Windows Tier 2 on 8befb406a reached frontend/obs-studio.vcxproj and stopped on 24 C4458/C4456 name-hiding findings, all first-party and all in parameter/local declarations: - SourceTreeItem.cpp.hpp (13): the seven signal-handler lambda parameters named `data`, the two `lock` guards in enterEvent/leaveEvent, the two undo/redo `data` arguments and the two `OBSDataAutoRelease data` locals. Renamed to handler_data, select_lock, uuid and privData (the constructor already used privData for the same object). - OBSBasicSourceSelect.cpp.hpp (4): the local `newSource` hiding the class member (-> createdSource), the two undo/redo `data` (-> uuid) and one scene-enumeration callback parameter (-> handler_data). - OBSBasicFilters.cpp.hpp (4) and OBSBasicTransform.cpp.hpp (1): the undo/redo JSON arguments named `data` (-> json). - OBSBasicVCamConfig.cpp.hpp (1): an obs_enum_sources callback parameter (-> handler_data). - OBSBasicAdvAudio.cpp.hpp (1, C4456): the range-for binding `control` hid the preceding local of the same name (-> ctrl). Renames only: no behaviour change, no new exemptions, and ci/test_msvc_warning_level.py needs no change (these are source fixes, not flags). Local: ci.test_msvc_warning_level 15 tests OK, ./lint ok (44.4 s). Refs #2626 --- frontend/components/SourceTreeItem.cpp.hpp | 48 +++++++++---------- frontend/dialogs/OBSBasicAdvAudio.cpp.hpp | 4 +- frontend/dialogs/OBSBasicFilters.cpp.hpp | 16 +++---- frontend/dialogs/OBSBasicSourceSelect.cpp.hpp | 22 ++++----- frontend/dialogs/OBSBasicTransform.cpp.hpp | 6 +-- frontend/dialogs/OBSBasicVCamConfig.cpp.hpp | 4 +- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/frontend/components/SourceTreeItem.cpp.hpp b/frontend/components/SourceTreeItem.cpp.hpp index df900a9ec4..434156bdec 100644 --- a/frontend/components/SourceTreeItem.cpp.hpp +++ b/frontend/components/SourceTreeItem.cpp.hpp @@ -185,8 +185,8 @@ void SourceTreeItem::ReconnectSignals() /* --------------------------------------------------------- */ - auto removeItem = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto removeItem = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); OBSSceneItem curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); OBSScene curScene = (obs_scene_t *)calldata_ptr(cd, "scene"); @@ -199,8 +199,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemVisible = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemVisible = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); bool visible = calldata_bool(cd, "visible"); @@ -209,8 +209,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemLocked = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemLocked = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); bool locked = calldata_bool(cd, "locked"); @@ -219,8 +219,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemSelect = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemSelect = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); if (curItem == this_->sceneitem) { @@ -228,8 +228,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemDeselect = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemDeselect = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); if (curItem == this_->sceneitem) { @@ -237,8 +237,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto reorderGroup = [](void *data, calldata_t *) { - SourceTreeItem *this_ = static_cast(data); + auto reorderGroup = [](void *handler_data, calldata_t *) { + SourceTreeItem *this_ = static_cast(handler_data); QMetaObject::invokeMethod(this_->tree, &SourceTree::ReorderItems); }; @@ -262,8 +262,8 @@ void SourceTreeItem::ReconnectSignals() /* --------------------------------------------------------- */ - auto removeSource = [](void *data, calldata_t *) { - SourceTreeItem *this_ = static_cast(data); + auto removeSource = [](void *handler_data, calldata_t *) { + SourceTreeItem *this_ = static_cast(handler_data); this_->DisconnectSignals(); this_->sceneitem = nullptr; QMetaObject::invokeMethod(this_->tree, &SourceTree::RefreshItems); @@ -300,7 +300,7 @@ void SourceTreeItem::enterEvent(QEnterEvent *event) OBSBasicPreview *preview = OBSBasicPreview::Get(); - std::lock_guard lock(preview->selectMutex); + std::lock_guard select_lock(preview->selectMutex); preview->hoveredPreviewItems.clear(); preview->hoveredPreviewItems.push_back(sceneitem); } @@ -311,7 +311,7 @@ void SourceTreeItem::leaveEvent(QEvent *event) OBSBasicPreview *preview = OBSBasicPreview::Get(); - std::lock_guard lock(preview->selectMutex); + std::lock_guard select_lock(preview->selectMutex); preview->hoveredPreviewItems.clear(); } @@ -407,8 +407,8 @@ void SourceTreeItem::ExitEditModeInternal(bool save) QSignalBlocker sourcesSignalBlocker(this); std::string prevName(obs_source_get_name(source)); std::string scene_uuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo = [scene_uuid, prevName, main](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto undo = [scene_uuid, prevName, main](const std::string &uuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_set_name(source, prevName.c_str()); OBSSourceAutoRelease scene_source = obs_get_source_by_uuid(scene_uuid.c_str()); @@ -417,8 +417,8 @@ void SourceTreeItem::ExitEditModeInternal(bool save) std::string editedName = newName; - auto redo = [scene_uuid, main, editedName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto redo = [scene_uuid, main, editedName](const std::string &uuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_set_name(source, editedName.c_str()); OBSSourceAutoRelease scene_source = obs_get_source_by_uuid(scene_uuid.c_str()); @@ -528,9 +528,9 @@ void SourceTreeItem::Update(bool force) ConfigurePlatformSourceItemWidget(expand); boxLayout->insertWidget(0, expand); - OBSDataAutoRelease data = obs_sceneitem_get_private_settings(sceneitem); + OBSDataAutoRelease privData = obs_sceneitem_get_private_settings(sceneitem); expand->blockSignals(true); - expand->setChecked(obs_data_get_bool(data, "collapsed")); + expand->setChecked(obs_data_get_bool(privData, "collapsed")); expand->blockSignals(false); connect(expand, &QPushButton::toggled, this, &SourceTreeItem::ExpandClicked); @@ -543,9 +543,9 @@ void SourceTreeItem::Update(bool force) void SourceTreeItem::ExpandClicked(bool checked) { - OBSDataAutoRelease data = obs_sceneitem_get_private_settings(sceneitem); + OBSDataAutoRelease privData = obs_sceneitem_get_private_settings(sceneitem); - obs_data_set_bool(data, "collapsed", checked); + obs_data_set_bool(privData, "collapsed", checked); if (!checked) { tree->GetStm()->ExpandGroup(sceneitem); diff --git a/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp b/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp index 3461768d3d..1a91f30c02 100644 --- a/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp +++ b/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp @@ -84,8 +84,8 @@ inline void OBSBasicAdvAudio::AddAudioSource(obs_source_t *source) InsertQObjectByName(controls, control); - for (auto control : controls) { - control->ShowAudioControl(ui->mainLayout); + for (auto *ctrl : controls) { + ctrl->ShowAudioControl(ui->mainLayout); } } diff --git a/frontend/dialogs/OBSBasicFilters.cpp.hpp b/frontend/dialogs/OBSBasicFilters.cpp.hpp index 261d76d804..4a148d2528 100644 --- a/frontend/dialogs/OBSBasicFilters.cpp.hpp +++ b/frontend/dialogs/OBSBasicFilters.cpp.hpp @@ -546,22 +546,22 @@ void OBSBasicFilters::AddNewFilter(const char *id) obs_data_set_string(uwrapper, "fname", obs_source_get_name(filter)); obs_data_set_string(uwrapper, "suuid", parent_uuid.c_str()); - auto undo = [scene_uuid](const std::string &data) { + auto undo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid")); OBSSourceAutoRelease filter = obs_source_get_filter_by_name(source, obs_data_get_string(dat, "fname")); obs_source_filter_remove(source, filter); }; - auto redo = [scene_uuid](const std::string &data) { + auto redo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid")); OBSSourceAutoRelease filter = obs_load_source(dat); obs_source_filter_add(source, filter); @@ -1067,11 +1067,11 @@ void OBSBasicFilters::delete_filter(OBSSource filter) obs_data_set_string(wrapper, "undo_uuid", parent_uuid.c_str()); std::string scene_uuid = obs_source_get_uuid(OBSBasic::Get()->GetCurrentSceneSource()); - auto undo = [scene_uuid](const std::string &data) { + auto undo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid")); OBSSourceAutoRelease filter = obs_load_source(dat); obs_source_filter_add(source, filter); @@ -1080,11 +1080,11 @@ void OBSBasicFilters::delete_filter(OBSSource filter) OBSDataAutoRelease rwrapper = obs_data_create(); obs_data_set_string(rwrapper, "fname", obs_source_get_name(filter)); obs_data_set_string(rwrapper, "suuid", parent_uuid.c_str()); - auto redo = [scene_uuid](const std::string &data) { + auto redo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid")); OBSSourceAutoRelease filter = obs_source_get_filter_by_name(source, obs_data_get_string(dat, "fname")); obs_source_filter_remove(source, filter); diff --git a/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp b/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp index f4d263542f..77d64ec208 100644 --- a/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp +++ b/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp @@ -713,12 +713,12 @@ void OBSBasicSourceSelect::createNew() return; } - OBSSource newSource = createResult.value(); - if (strcmp(obs_source_get_id(newSource), "group") == 0) { + OBSSource createdSource = createResult.value(); + if (strcmp(obs_source_get_id(createdSource), "group") == 0) { return; } - std::optional addResult = setupExistingSource(obs_source_get_uuid(newSource), visible, false); + std::optional addResult = setupExistingSource(obs_source_get_uuid(createdSource), visible, false); if (!addResult.has_value()) { return; } @@ -727,10 +727,10 @@ void OBSBasicSourceSelect::createNew() OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); std::string sceneUuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo = [sceneUuid](const std::string &data) { + auto undo = [sceneUuid](const std::string &uuid) { OBSBasic *main = OBSBasic::Get(); - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_remove(source); OBSSourceAutoRelease sceneSource = obs_get_source_by_uuid(sceneUuid.c_str()); @@ -742,13 +742,13 @@ void OBSBasicSourceSelect::createNew() obs_data_set_string(wrapper, "name", newName.c_str()); obs_data_set_bool(wrapper, "visible", visible); - auto redo = [sceneUuid](const std::string &data) { + auto redo = [sceneUuid](const std::string &uuid) { OBSBasic *main = OBSBasic::Get(); OBSSourceAutoRelease sceneSource = obs_get_source_by_uuid(sceneUuid.c_str()); main->SetCurrentScene(sceneSource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(uuid.c_str()); std::optional createResult = setupNewSource(NULL, obs_data_get_string(dat, "id"), obs_data_get_string(dat, "name")); @@ -769,9 +769,9 @@ void OBSBasicSourceSelect::createNew() obs_sceneitem_set_id(item, static_cast(obs_data_get_int(dat, "item_id"))); }; undo_s.add_action(QTStr("Undo.Add").arg(QString::fromStdString(newName)), undo, redo, - std::string(obs_source_get_uuid(newSource)), std::string(obs_data_get_json(wrapper))); + std::string(obs_source_get_uuid(createdSource)), std::string(obs_data_get_json(wrapper))); - main->CreatePropertiesWindow(newSource); + main->CreatePropertiesWindow(createdSource); close(); } @@ -800,8 +800,8 @@ void OBSBasicSourceSelect::addExisting(const std::string &uuid, bool visible) OBSScene scene = obs_scene_from_source(sceneSource); OBSSceneItem item; - auto cb = [](obs_scene_t *, obs_sceneitem_t *sceneitem, void *data) { - OBSSceneItem &last = *static_cast(data); + auto cb = [](obs_scene_t *, obs_sceneitem_t *sceneitem, void *handler_data) { + OBSSceneItem &last = *static_cast(handler_data); last = sceneitem; return true; }; diff --git a/frontend/dialogs/OBSBasicTransform.cpp.hpp b/frontend/dialogs/OBSBasicTransform.cpp.hpp index 2f3ef35b58..98fdc198b2 100644 --- a/frontend/dialogs/OBSBasicTransform.cpp.hpp +++ b/frontend/dialogs/OBSBasicTransform.cpp.hpp @@ -114,11 +114,11 @@ OBSBasicTransform::~OBSBasicTransform() { OBSDataAutoRelease wrapper = obs_scene_save_transform_states(main->GetCurrentScene(), false); - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &json) { + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid")); OBSBasic::Get()->SetCurrentScene(source.Get(), true); - obs_scene_load_transform_states(data.c_str()); + obs_scene_load_transform_states(json.c_str()); }; std::string redo_data(obs_data_get_json(wrapper)); diff --git a/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp b/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp index 6d571e03c1..d9dd9bd348 100644 --- a/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp +++ b/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp @@ -65,8 +65,8 @@ void OBSBasicVCamConfig::OutputTypeChanged() using AddSource_t = decltype(AddSource); obs_enum_sources( - [](void *data, obs_source_t *source) { - auto &AddSource = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &AddSource = *static_cast(handler_data); if (!obs_source_removed(source)) { AddSource(source); } From 64b29f37460a48f14c331f890945f123888dfbda Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 14:59:17 -0700 Subject: [PATCH 46/63] build(msvc): name the properties undo/redo blob after its content, not the member (#2626) Wave 17: the /W4 x64 and arm64 log of 40771676539 reports exactly one finding left in the Qt frontend -- C4458 at OBSBasicProperties.cpp.hpp:270, where the undo/redo lambda's 'data' parameter hides a class member. Name it 'json', the serialized blob it is. --- frontend/dialogs/OBSBasicProperties.cpp.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/dialogs/OBSBasicProperties.cpp.hpp b/frontend/dialogs/OBSBasicProperties.cpp.hpp index 43ad01b0dc..d6b5fbb921 100644 --- a/frontend/dialogs/OBSBasicProperties.cpp.hpp +++ b/frontend/dialogs/OBSBasicProperties.cpp.hpp @@ -267,8 +267,8 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button) std::string scene_uuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo_redo = [scene_uuid](const std::string &data) { - OBSDataAutoRelease settings = obs_data_create_from_json(data.c_str()); + auto undo_redo = [scene_uuid](const std::string &json) { + OBSDataAutoRelease settings = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(settings, "undo_uuid")); obs_source_reset_settings(source, settings); From 3ecc3dc5ddd571d6c5b9d023e73bf7a46eca1aeb Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 15:15:48 -0700 Subject: [PATCH 47/63] build(msvc): name the importer locals after what they hold (#2626) Wave 18: the /W4 x64 log of 40776407182 reports five findings left in the Streamlabs/XSplit importers, all name-hiding in loop bodies: sl.cpp.hpp:275,328,375 C4457 'name' hides the attempt_import parameter xsplit.cpp.hpp:332 C4456 'name' hides the loop's previous local xsplit.cpp.hpp:356 C4456 'source' hides the loop's Json source Renames only, at the declaration: source_name / imported_scene_name / imported_transition_name / window_name / linked_source. The goto-skip path and the window_capture "::" concatenation keep their existing behaviour. --- frontend/importers/sl.cpp.hpp | 18 +++++++++--------- frontend/importers/xsplit.cpp.hpp | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/importers/sl.cpp.hpp b/frontend/importers/sl.cpp.hpp index 6b5a06db46..1e3c0c343b 100644 --- a/frontend/importers/sl.cpp.hpp +++ b/frontend/importers/sl.cpp.hpp @@ -272,7 +272,7 @@ static int attempt_import(const Json &root, const string &name, Json &res) double vol = source["volume"].number_value(); bool muted = source["muted"].bool_value(); - string name = source["name"].string_value(); + string source_name = source["name"].string_value(); int monitoring = (int)source["monitoringType"].int_value(); Json::object out_hotkeys = Json::object{}; @@ -288,9 +288,9 @@ static int attempt_import(const Json &root, const string &name, Json &res) } int copy = 1; - string out_name = name; + string out_name = source_name; while (sl_source_name_exists(out_sources, out_name)) { - out_name = name + "(" + to_string(copy++) + ")"; + out_name = source_name + "(" + to_string(copy++) + ")"; } string sl_id = source["id"].string_value(); @@ -325,7 +325,7 @@ static int attempt_import(const Json &root, const string &name, Json &res) Json in_settings = scene["settings"]; - string name = scene["name"].string_value(); + string imported_scene_name = scene["name"].string_value(); Json::object out_hotkeys = Json::object{}; get_hotkey_bindings(out_hotkeys, hotkey_items, ""); @@ -340,9 +340,9 @@ static int attempt_import(const Json &root, const string &name, Json &res) } int copy = 1; - string out_name = name; + string out_name = imported_scene_name; while (sl_source_name_exists(out_sources, out_name)) { - out_name = name + "(" + to_string(copy++) + ")"; + out_name = imported_scene_name + "(" + to_string(copy++) + ")"; } if (scene_name.empty()) { @@ -372,16 +372,16 @@ static int attempt_import(const Json &root, const string &name, Json &res) Json in_settings = transition["settings"]; int duration = transition["duration"].int_value(); - string name = transition["name"].string_value(); + string imported_transition_name = transition["name"].string_value(); string id = transition["id"].string_value(); if (id == t_id) { - transition_name = name; + transition_name = imported_transition_name; } out_transitions.push_back(Json::object{{"id", transition["type"]}, {"settings", in_settings}, - {"name", name}, + {"name", imported_transition_name}, {"duration", duration}}); } diff --git a/frontend/importers/xsplit.cpp.hpp b/frontend/importers/xsplit.cpp.hpp index 0874451a24..1e81a4c81c 100644 --- a/frontend/importers/xsplit.cpp.hpp +++ b/frontend/importers/xsplit.cpp.hpp @@ -329,10 +329,10 @@ static void parse_items(QDomNode &item, Json::array &items, Json::array &sources QDomNode el = doc.documentElement(); QDomNamedNodeMap o_attr = el.attributes(); - QString name = o_attr.namedItem("wndname").nodeValue(); + QString window_name = o_attr.namedItem("wndname").nodeValue(); QString exec = o_attr.namedItem("imagename").nodeValue(); - QString res = name = "::" + exec; + QString res = window_name = "::" + exec; source["id"] = "game_capture"; settings["window"] = res.toStdString(); @@ -353,8 +353,8 @@ static void parse_items(QDomNode &item, Json::array &items, Json::array &sources } } else if (type == 11) { QString id = attr.namedItem("item").nodeValue(); - Json source = get_source_with_id(id.toStdString(), sources); - name = source["name"].string_value(); + Json linked_source = get_source_with_id(id.toStdString(), sources); + name = linked_source["name"].string_value(); goto skip; } From fd967f7d0c0cad1f48011116e917281f7a7f598e Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 15:33:35 -0700 Subject: [PATCH 48/63] build(msvc): name the settings locals and handler params after their role (#2626) Wave 19: the /W4 x64 log of 40778602578 reaches the settings tabs and reports 28 findings across four files, all name-hiding at the declaration: OBSBasicSettings.cpp.hpp (18) 'data' lambda/callback params -> handler_data, with data/local variants named for content (saved_settings, bindings_data, hotkey_enum_data), 'preset' -> preset_value / selected_preset / preset_name, 'protocol' -> service_protocol, 'hotkeys' -> hotkeys_widget OBSBasicSettings_Stream.cpp.hpp (9) member params 'protocol' -> protocol_name, 'idx' -> encoder_idx, shadowed 'settings' -> probe_settings OBSHotkeyWidget.cpp.hpp (1) enum callback param -> handler_data AuthListener.cpp.hpp (1) SetState param 'state' -> newState Renames only; behaviour is unchanged at every site. The header declarations that name these parameters follow. --- frontend/oauth/AuthListener.cpp.hpp | 4 +- frontend/oauth/AuthListener.hpp | 2 +- frontend/settings/OBSBasicSettings.cpp.hpp | 93 ++++++++++--------- frontend/settings/OBSBasicSettings.hpp | 4 +- .../settings/OBSBasicSettings_Stream.cpp.hpp | 60 ++++++------ frontend/settings/OBSHotkeyWidget.cpp.hpp | 4 +- 6 files changed, 84 insertions(+), 83 deletions(-) diff --git a/frontend/oauth/AuthListener.cpp.hpp b/frontend/oauth/AuthListener.cpp.hpp index 6cf987c976..e83af41f60 100644 --- a/frontend/oauth/AuthListener.cpp.hpp +++ b/frontend/oauth/AuthListener.cpp.hpp @@ -33,9 +33,9 @@ quint16 AuthListener::GetPort() return server ? server->serverPort() : 0; } -void AuthListener::SetState(QString state) +void AuthListener::SetState(QString newState) { - this->state = state; + this->state = newState; } void AuthListener::NewConnection() diff --git a/frontend/oauth/AuthListener.hpp b/frontend/oauth/AuthListener.hpp index 65bcf540ec..d27f6ae94d 100644 --- a/frontend/oauth/AuthListener.hpp +++ b/frontend/oauth/AuthListener.hpp @@ -20,5 +20,5 @@ class AuthListener : public QObject { public: explicit AuthListener(QObject *parent = 0); quint16 GetPort(); - void SetState(QString state); + void SetState(QString newState); }; diff --git a/frontend/settings/OBSBasicSettings.cpp.hpp b/frontend/settings/OBSBasicSettings.cpp.hpp index bc6b651efc..f74535b02d 100644 --- a/frontend/settings/OBSBasicSettings.cpp.hpp +++ b/frontend/settings/OBSBasicSettings.cpp.hpp @@ -716,8 +716,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) LoadColorFormats(); LoadFormats(); - auto ReloadAudioSources = [](void *data, calldata_t *param) { - auto settings = static_cast(data); + auto ReloadAudioSources = [](void *handler_data, calldata_t *param) { + auto settings = static_cast(handler_data); auto source = static_cast(calldata_ptr(param, "source")); if (!source) { @@ -735,14 +735,14 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) hotkeyConflictIcon = QIcon::fromTheme("obs", QIcon(":/res/images/warning.svg")); - auto ReloadHotkeys = [](void *data, calldata_t *) { - auto settings = static_cast(data); + auto ReloadHotkeys = [](void *handler_data, calldata_t *) { + auto settings = static_cast(handler_data); QMetaObject::invokeMethod(settings, &OBSBasicSettings::ReloadHotkeys, OBS_INVALID_HOTKEY_ID); }; hotkeyRegistered.Connect(obs_get_signal_handler(), "hotkey_register", ReloadHotkeys, this); - auto ReloadHotkeysIgnore = [](void *data, calldata_t *param) { - auto settings = static_cast(data); + auto ReloadHotkeysIgnore = [](void *handler_data, calldata_t *param) { + auto settings = static_cast(handler_data); auto key = static_cast(calldata_ptr(param, "key")); QMetaObject::invokeMethod(settings, &OBSBasicSettings::ReloadHotkeys, obs_hotkey_get_id(key)); }; @@ -1759,7 +1759,7 @@ void OBSBasicSettings::LoadSimpleOutputSettings() const char *streamAudioEnc = config_get_string(main->Config(), "SimpleOutput", "StreamAudioEncoder"); int audioBitrate = config_get_uint(main->Config(), "SimpleOutput", "ABitrate"); bool advanced = config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced"); - const char *preset = config_get_string(main->Config(), "SimpleOutput", "Preset"); + const char *preset_value = config_get_string(main->Config(), "SimpleOutput", "Preset"); const char *qsvPreset = config_get_string(main->Config(), "SimpleOutput", "QSVPreset"); const char *nvPreset = config_get_string(main->Config(), "SimpleOutput", "NVENCPreset2"); const char *amdPreset = config_get_string(main->Config(), "SimpleOutput", "AMDPreset"); @@ -1781,7 +1781,7 @@ void OBSBasicSettings::LoadSimpleOutputSettings() ui->simpleOutRecTrack5->setChecked(tracks & (1 << 4)); ui->simpleOutRecTrack6->setChecked(tracks & (1 << 5)); - curPreset = preset; + curPreset = preset_value; curQSVPreset = qsvPreset; curNVENCPreset = nvPreset; curAMDPreset = amdPreset; @@ -1930,9 +1930,9 @@ void OBSBasicSettings::LoadAdvOutputStreamingSettings() ui->advOutMultiTrack6->setChecked(audioMixes & (1 << 5)); obs_service_t *service_obj = main->GetService(); - const char *protocol = nullptr; - protocol = obs_service_get_protocol(service_obj); - SwapMultiTrack(protocol); + const char *service_protocol = nullptr; + service_protocol = obs_service_get_protocol(service_obj); + SwapMultiTrack(service_protocol); } OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(const char *encoder, const char *path, bool changed) @@ -1947,9 +1947,10 @@ OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(const char *encod const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(path); if (!jsonFilePath.empty()) { - obs_data_t *data = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - obs_data_apply(settings, data); - obs_data_release(data); + obs_data_t *saved_settings = + obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); + obs_data_apply(settings, saved_settings); + obs_data_release(saved_settings); } } @@ -2485,32 +2486,32 @@ void OBSBasicSettings::LoadAudioSources() auto handler = obs_source_get_signal_handler(source); audioSourceSignals.emplace_back( handler, "push_to_mute_changed", - [](void *data, calldata_t *param) { - auto checkBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto checkBox = static_cast(handler_data); bool enabled = calldata_bool(param, "enabled"); QMetaObject::invokeMethod(checkBox, &SilentUpdateCheckBox::setCheckedSilently, enabled); }, ptmCB); audioSourceSignals.emplace_back( handler, "push_to_mute_delay", - [](void *data, calldata_t *param) { - auto spinBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto spinBox = static_cast(handler_data); auto delay = static_cast(calldata_int(param, "delay")); QMetaObject::invokeMethod(spinBox, &SilentUpdateSpinBox::setValueSilently, delay); }, ptmSB); audioSourceSignals.emplace_back( handler, "push_to_talk_changed", - [](void *data, calldata_t *param) { - auto checkBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto checkBox = static_cast(handler_data); bool enabled = calldata_bool(param, "enabled"); QMetaObject::invokeMethod(checkBox, &SilentUpdateCheckBox::setCheckedSilently, enabled); }, pttCB); audioSourceSignals.emplace_back( handler, "push_to_talk_delay", - [](void *data, calldata_t *param) { - auto spinBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto spinBox = static_cast(handler_data); auto delay = static_cast(calldata_int(param, "delay")); QMetaObject::invokeMethod(spinBox, &SilentUpdateSpinBox::setValueSilently, delay); }, @@ -2533,8 +2534,8 @@ void OBSBasicSettings::LoadAudioSources() using AddSource_t = decltype(AddSource); obs_enum_sources( - [](void *data, obs_source_t *source) { - auto &AddSource = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &AddSource = *static_cast(handler_data); if (!obs_source_removed(source)) { AddSource(source); } @@ -2937,8 +2938,8 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) using keys_t = map>; keys_t keys; obs_enum_hotkey_bindings( - [](void *data, size_t, obs_hotkey_binding_t *binding) { - auto &keys = *static_cast(data); + [](void *handler_data, size_t, obs_hotkey_binding_t *binding) { + auto &keys = *static_cast(handler_data); keys[obs_hotkey_binding_get_hotkey_id(binding)].emplace_back( obs_hotkey_binding_get_key_combination(binding)); @@ -3081,8 +3082,8 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) }); }; - auto data = make_tuple(RegisterHotkey, std::move(keys), ignoreKey, this); - using data_t = decltype(data); + auto hotkey_enum_data = make_tuple(RegisterHotkey, std::move(keys), ignoreKey, this); + using data_t = decltype(hotkey_enum_data); obs_enum_hotkeys( [](void *data, obs_hotkey_id id, obs_hotkey_t *key) { data_t &d = *static_cast(data); @@ -3091,7 +3092,7 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) } return true; }, - &data); + &hotkey_enum_data); for (auto keyId : pairIds) { auto data1 = pairLabels.find(keyId); @@ -3887,9 +3888,9 @@ void OBSBasicSettings::SaveHotkeySettings() OBSDataArrayAutoRelease array = obs_hotkey_save(hw.id); OBSBasic::MarkSavedHotkeys(array); - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_array(data, "bindings", array); - const char *json = obs_data_get_json(data); + OBSDataAutoRelease bindings_data = obs_data_create(); + obs_data_set_array(bindings_data, "bindings", array); + const char *json = obs_data_get_json(bindings_data); config_set_string(config, "Hotkeys", hw.name.c_str(), json); } } @@ -4633,12 +4634,12 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, obs_key_combination_t ui->hotkeyScrollArea->ensureVisible(0, 0); QLayoutItem *hotkeysItem = ui->hotkeyFormLayout->itemAt(0); - QWidget *hotkeys = hotkeysItem->widget(); - if (!hotkeys) { + QWidget *hotkeys_widget = hotkeysItem->widget(); + if (!hotkeys_widget) { return; } - QFormLayout *hotkeysLayout = qobject_cast(hotkeys->layout()); + QFormLayout *hotkeysLayout = qobject_cast(hotkeys_widget->layout()); hotkeysLayout->setEnabled(false); QString needle = text.toLower(); @@ -5151,7 +5152,7 @@ extern const char *get_simple_output_encoder(const char *encoder); void OBSBasicSettings::SimpleStreamingEncoderChanged() { QString encoder = ui->simpleOutStrEncoder->currentData().toString(); - QString preset; + QString selected_preset; const char *defaultPreset = nullptr; ui->simpleOutAdvanced->setVisible(true); @@ -5165,7 +5166,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("quality", "quality"); defaultPreset = "balanced"; - preset = curQSVPreset; + selected_preset = curQSVPreset; } else if (encoder == SIMPLE_ENCODER_NVENC || encoder == SIMPLE_ENCODER_NVENC_HEVC || encoder == SIMPLE_ENCODER_NVENC_AV1) { @@ -5177,14 +5178,14 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() obs_property_t *p = obs_properties_get(props, isFFmpegEncoder ? "preset2" : "preset"); size_t num = obs_property_list_item_count(p); for (size_t i = 0; i < num; i++) { - const char *name = obs_property_list_item_name(p, i); + const char *preset_name = obs_property_list_item_name(p, i); const char *val = obs_property_list_item_string(p, i); - ui->simpleOutPreset->addItem(QT_UTF8(name), val); + ui->simpleOutPreset->addItem(QT_UTF8(preset_name), val); } defaultPreset = "default"; - preset = curNVENCPreset; + selected_preset = curNVENCPreset; } else if (encoder == SIMPLE_ENCODER_AMD || encoder == SIMPLE_ENCODER_AMD_HEVC) { ui->simpleOutPreset->addItem("Speed", "speed"); @@ -5192,7 +5193,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("Quality", "quality"); defaultPreset = "balanced"; - preset = curAMDPreset; + selected_preset = curAMDPreset; } else if (encoder == SIMPLE_ENCODER_APPLE_H264 #ifdef ENABLE_HEVC || encoder == SIMPLE_ENCODER_APPLE_HEVC @@ -5210,7 +5211,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("High Quality", "highQuality"); defaultPreset = "balanced"; - preset = curAMDAV1Preset; + selected_preset = curAMDAV1Preset; } else { #define PRESET_STR(val) QString(Str("Basic.Settings.Output.EncoderPreset." val)).arg(val) @@ -5232,10 +5233,10 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() } defaultPreset = "veryfast"; - preset = curPreset; + selected_preset = curPreset; } - int idx = ui->simpleOutPreset->findData(QVariant(preset)); + int idx = ui->simpleOutPreset->findData(QVariant(selected_preset)); if (idx == -1) { idx = ui->simpleOutPreset->findData(QVariant(defaultPreset)); } @@ -5361,9 +5362,9 @@ void OBSBasicSettings::AdvReplayBufferChanged() currentProfile.path / std::filesystem::u8path("recordEncoder.json"); if (!jsonFilePath.empty()) { - OBSDataAutoRelease data = + OBSDataAutoRelease saved_settings = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - obs_data_apply(settings, data); + obs_data_apply(settings, saved_settings); } } diff --git a/frontend/settings/OBSBasicSettings.hpp b/frontend/settings/OBSBasicSettings.hpp index f262482f71..74fe6eea1f 100644 --- a/frontend/settings/OBSBasicSettings.hpp +++ b/frontend/settings/OBSBasicSettings.hpp @@ -352,8 +352,8 @@ private slots: bool ServiceAndACodecCompatible(); bool ServiceSupportsCodecCheck(); - inline bool AllowsMultiTrack(const char *protocol); - void SwapMultiTrack(const char *protocol); + inline bool AllowsMultiTrack(const char *protocol_name); + void SwapMultiTrack(const char *protocol_name); private slots: void on_theme_activated(int idx); diff --git a/frontend/settings/OBSBasicSettings_Stream.cpp.hpp b/frontend/settings/OBSBasicSettings_Stream.cpp.hpp index a6eac3f857..9290073ff4 100644 --- a/frontend/settings/OBSBasicSettings_Stream.cpp.hpp +++ b/frontend/settings/OBSBasicSettings_Stream.cpp.hpp @@ -294,16 +294,16 @@ void OBSBasicSettings::LoadStream1Settings() #define SRT_PROTOCOL "srt" #define RIST_PROTOCOL "rist" -bool OBSBasicSettings::AllowsMultiTrack(const char *protocol) +bool OBSBasicSettings::AllowsMultiTrack(const char *protocol_name) { - return astrcmpi_n(protocol, SRT_PROTOCOL, strlen(SRT_PROTOCOL)) == 0 || - astrcmpi_n(protocol, RIST_PROTOCOL, strlen(RIST_PROTOCOL)) == 0; + return astrcmpi_n(protocol_name, SRT_PROTOCOL, strlen(SRT_PROTOCOL)) == 0 || + astrcmpi_n(protocol_name, RIST_PROTOCOL, strlen(RIST_PROTOCOL)) == 0; } -void OBSBasicSettings::SwapMultiTrack(const char *protocol) +void OBSBasicSettings::SwapMultiTrack(const char *protocol_name) { - if (protocol) { - if (AllowsMultiTrack(protocol)) { + if (protocol_name) { + if (AllowsMultiTrack(protocol_name)) { ui->advStreamTrackWidget->setCurrentWidget(ui->streamMultiTracks); } else { ui->advStreamTrackWidget->setCurrentWidget(ui->streamSingleTracks); @@ -394,12 +394,12 @@ void OBSBasicSettings::SaveStream1Settings() auto oldMultitrackVideoSetting = config_get_bool(main->Config(), "Stream1", "EnableMultitrackVideo"); if (!IsCustomService()) { - OBSDataAutoRelease settings = obs_data_create(); - obs_data_set_string(settings, "service", QT_TO_UTF8(ui->service->currentText())); + OBSDataAutoRelease probe_settings = obs_data_create(); + obs_data_set_string(probe_settings, "service", QT_TO_UTF8(ui->service->currentText())); OBSServiceAutoRelease temp_service = - obs_service_create_private("rtmp_common", "auto config query service", settings); - settings = obs_service_get_settings(temp_service); - auto available = obs_data_has_user_value(settings, "multitrack_video_configuration_url"); + obs_service_create_private("rtmp_common", "auto config query service", probe_settings); + probe_settings = obs_service_get_settings(temp_service); + auto available = obs_data_has_user_value(probe_settings, "multitrack_video_configuration_url"); if (available) { SaveCheckBox(ui->enableMultitrackVideo, "Stream1", "EnableMultitrackVideo"); @@ -793,9 +793,9 @@ QString OBSBasicSettings::FindProtocol() obs_data_set_string(settings, "service", QT_TO_UTF8(ui->service->currentText())); obs_property_modified(services, settings); - const char *protocol = obs_data_get_string(settings, "protocol"); - if (protocol && *protocol) { - return QT_UTF8(protocol); + const char *protocol_name = obs_data_get_string(settings, "protocol"); + if (protocol_name && *protocol_name) { + return QT_UTF8(protocol_name); } } @@ -1872,55 +1872,55 @@ void OBSBasicSettings::ResetEncoders(bool streamOnly) /* Find fallback encoders */ if (!lastAdvVideoEnc.isEmpty()) { - int idx = ui->advOutEncoder->findData(lastAdvVideoEnc); - if (idx == -1) { + int encoder_idx = ui->advOutEncoder->findData(lastAdvVideoEnc); + if (encoder_idx == -1) { lastAdvVideoEnc = get_adv_fallback(lastAdvVideoEnc); ui->advOutEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->advOutEncoder->findData(lastAdvVideoEnc); + encoder_idx = ui->advOutEncoder->findData(lastAdvVideoEnc); s2.unblock(); - ui->advOutEncoder->setCurrentIndex(idx); + ui->advOutEncoder->setCurrentIndex(encoder_idx); } if (!lastAdvAudioEnc.isEmpty()) { - int idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); - if (idx == -1) { + int encoder_idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); + if (encoder_idx == -1) { lastAdvAudioEnc = get_adv_audio_fallback(lastAdvAudioEnc); ui->advOutAEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); + encoder_idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); s4.unblock(); - ui->advOutAEncoder->setCurrentIndex(idx); + ui->advOutAEncoder->setCurrentIndex(encoder_idx); } if (!lastVideoEnc.isEmpty()) { - int idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); - if (idx == -1) { + int encoder_idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); + if (encoder_idx == -1) { lastVideoEnc = get_simple_fallback(lastVideoEnc); ui->simpleOutStrEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); + encoder_idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); s1.unblock(); - ui->simpleOutStrEncoder->setCurrentIndex(idx); + ui->simpleOutStrEncoder->setCurrentIndex(encoder_idx); } if (!lastAudioEnc.isEmpty()) { - int idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); - if (idx == -1) { + int encoder_idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); + if (encoder_idx == -1) { lastAudioEnc = (lastAudioEnc == "opus") ? "aac" : "opus"; ui->simpleOutStrAEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); + encoder_idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); s3.unblock(); - ui->simpleOutStrAEncoder->setCurrentIndex(idx); + ui->simpleOutStrAEncoder->setCurrentIndex(encoder_idx); } } diff --git a/frontend/settings/OBSHotkeyWidget.cpp.hpp b/frontend/settings/OBSHotkeyWidget.cpp.hpp index 877b044e7a..0af2ff2a3d 100644 --- a/frontend/settings/OBSHotkeyWidget.cpp.hpp +++ b/frontend/settings/OBSHotkeyWidget.cpp.hpp @@ -221,8 +221,8 @@ void OBSHotkeyWidget::HandleChangedBindings(obs_hotkey_id id_) using LoadBindings_t = decltype(&LoadBindings); obs_enum_hotkey_bindings( - [](void *data, size_t, obs_hotkey_binding_t *binding) { - auto LoadBindings = *static_cast(data); + [](void *handler_data, size_t, obs_hotkey_binding_t *binding) { + auto LoadBindings = *static_cast(handler_data); LoadBindings(binding); return true; }, From 6f3ff51fee318975bd92546edcd43c17cad2c8f0 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 15:49:11 -0700 Subject: [PATCH 49/63] build(msvc): name the frontend utility locals after what they hold (#2626) Wave 20: the /W4 log of 40780896312 reaches the Qt frontend's utility layer and reports five findings in four files, identical on x64 (123143264750) and arm64 (123143264828), all name-hiding at the declaration: OBSBasicSettings.cpp.hpp(3088) C4458 hotkey-enum lambda param 'data' -> handler_data AdvancedOutput.cpp.hpp(570) C4457 local 'service' (the service name string) -> service_name AdvancedOutput.cpp.hpp(712) C4458 local copy of the streaming output 'streamOutput' -> streamOutputRef CrashHandler.cpp.hpp(128, 271) C4459 locals 'crashSentinelPath' (the sentinel directory) -> sentinel_dir Renames only; behaviour is unchanged at every site. The 'shadowing is sort of bad' comment on the output alias goes with the shadowing. --- frontend/settings/OBSBasicSettings.cpp.hpp | 4 ++-- frontend/utility/AdvancedOutput.cpp.hpp | 18 +++++++++--------- frontend/utility/CrashHandler.cpp.hpp | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/frontend/settings/OBSBasicSettings.cpp.hpp b/frontend/settings/OBSBasicSettings.cpp.hpp index f74535b02d..f2754169ed 100644 --- a/frontend/settings/OBSBasicSettings.cpp.hpp +++ b/frontend/settings/OBSBasicSettings.cpp.hpp @@ -3085,8 +3085,8 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) auto hotkey_enum_data = make_tuple(RegisterHotkey, std::move(keys), ignoreKey, this); using data_t = decltype(hotkey_enum_data); obs_enum_hotkeys( - [](void *data, obs_hotkey_id id, obs_hotkey_t *key) { - data_t &d = *static_cast(data); + [](void *handler_data, obs_hotkey_id id, obs_hotkey_t *key) { + data_t &d = *static_cast(handler_data); if (id != get<2>(d)) { LayoutHotkey(get<3>(d), id, key, get<0>(d), get<1>(d)); } diff --git a/frontend/utility/AdvancedOutput.cpp.hpp b/frontend/utility/AdvancedOutput.cpp.hpp index 4320b4ee8b..ed60188ded 100644 --- a/frontend/utility/AdvancedOutput.cpp.hpp +++ b/frontend/utility/AdvancedOutput.cpp.hpp @@ -567,8 +567,8 @@ inline std::optional AdvancedOutput::VodTrackMixerIdx(obs_service_t *ser vodTrackEnabled = enableForCustomServer ? vodTrackEnabled : false; } else { OBSDataAutoRelease settings = obs_service_get_settings(service); - const char *service = obs_data_get_string(settings, "service"); - if (!ServiceSupportsVodTrack(service)) { + const char *service_name = obs_data_get_string(settings, "service"); + if (!ServiceSupportsVodTrack(service_name)) { vodTrackEnabled = false; } } @@ -709,21 +709,21 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) SetOutputNetworkOptions(main->Config(), settings); obs_data_set_bool(settings, "dyn_bitrate", enableDynBitrate); - auto streamOutput = StreamingOutput(); // shadowing is sort of bad, but also convenient + auto streamOutputRef = StreamingOutput(); - obs_output_update(streamOutput, settings); + obs_output_update(streamOutputRef, settings); if (!reconnect) { maxRetries = 0; } - obs_output_set_delay(streamOutput, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); + obs_output_set_delay(streamOutputRef, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); - obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay); + obs_output_set_reconnect_settings(streamOutputRef, maxRetries, retryDelay); if (is_rtmp) { SetupVodTrack(service); } - if (obs_output_start(streamOutput)) { + if (obs_output_start(streamOutputRef)) { bool dumpStarted = false; if (multitrackVideo && multitrackVideoActive) { dumpStarted = multitrackVideo->StartedStreaming(); @@ -737,7 +737,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) multitrackVideoActive = false; } - const char *error = obs_output_get_last_error(streamOutput); + const char *error = obs_output_get_last_error(streamOutputRef); bool hasLastError = error && *error; if (hasLastError) { lastError = error; @@ -745,7 +745,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) lastError = string(); } - const char *type = obs_output_get_id(streamOutput); + const char *type = obs_output_get_id(streamOutputRef); blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type, hasLastError ? " Last Error: " : "", hasLastError ? error : ""); return false; diff --git a/frontend/utility/CrashHandler.cpp.hpp b/frontend/utility/CrashHandler.cpp.hpp index 5abfeec77a..17d90b19ac 100644 --- a/frontend/utility/CrashHandler.cpp.hpp +++ b/frontend/utility/CrashHandler.cpp.hpp @@ -125,13 +125,13 @@ void CrashHandler::checkCrashState() { bool currentSentinelFound = false; - std::filesystem::path crashSentinelPath = crashSentinelFile_.parent_path(); + std::filesystem::path sentinel_dir = crashSentinelFile_.parent_path(); - if (!ensure_crash_sentinel_dir(crashSentinelPath)) { + if (!ensure_crash_sentinel_dir(sentinel_dir)) { return; } - for (const auto &entry : std::filesystem::directory_iterator(crashSentinelPath)) { + for (const auto &entry : std::filesystem::directory_iterator(sentinel_dir)) { if (entry.is_directory()) { continue; } @@ -268,14 +268,14 @@ void CrashHandler::applicationShutdownHandler() noexcept return; } - const std::filesystem::path crashSentinelPath = crashSentinelFile_.parent_path(); + const std::filesystem::path sentinel_dir = crashSentinelFile_.parent_path(); - if (!std::filesystem::exists(crashSentinelPath)) { - blog(LOG_ERROR, "Crash sentinel location '%s' does not exist", crashSentinelPath.u8string().c_str()); + if (!std::filesystem::exists(sentinel_dir)) { + blog(LOG_ERROR, "Crash sentinel location '%s' does not exist", sentinel_dir.u8string().c_str()); return; } - for (const auto &entry : std::filesystem::directory_iterator(crashSentinelPath)) { + for (const auto &entry : std::filesystem::directory_iterator(sentinel_dir)) { if (entry.is_directory()) { continue; } From 3795bc7f47ec3c07512d4d5aac22bac1f91a6bdb Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 16:12:30 -0700 Subject: [PATCH 50/63] build(msvc): name the thumbnail and simple-output locals after their role (#2626) Wave 21: the /W4 x64 log of 40782858353 gets past the settings tabs and reports seven findings in the frontend utility layer, all name-hiding at the declaration: SimpleOutput.cpp.hpp:720 'streamOutput' local -> streamOutputRef ThumbnailItem.cpp.hpp:90,167 'pixmap' param/local -> newPixmap / blank_pixmap ThumbnailManager.cpp.hpp:254 'uuid' hides the param -> item_uuid ThumbnailView.cpp.hpp:42,60 'enabled'/'pixmap' params -> newEnabled / newPixmap audio-encoders.cpp.hpp:167 'ss' hides an outer local -> bitrate_list Renames only, and the setters' header declarations follow. The stale "shadowing is sort of bad" comment on the simple output alias goes too. --- frontend/utility/SimpleOutput.cpp.hpp | 16 ++++++++-------- frontend/utility/ThumbnailItem.cpp.hpp | 8 ++++---- frontend/utility/ThumbnailItem.hpp | 2 +- frontend/utility/ThumbnailManager.cpp.hpp | 4 ++-- frontend/utility/ThumbnailView.cpp.hpp | 12 ++++++------ frontend/utility/ThumbnailView.hpp | 4 ++-- frontend/utility/audio-encoders.cpp.hpp | 6 +++--- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/frontend/utility/SimpleOutput.cpp.hpp b/frontend/utility/SimpleOutput.cpp.hpp index bf8156be27..dd6f9d7065 100644 --- a/frontend/utility/SimpleOutput.cpp.hpp +++ b/frontend/utility/SimpleOutput.cpp.hpp @@ -717,23 +717,23 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) SetOutputNetworkOptions(main->Config(), settings); obs_data_set_bool(settings, "dyn_bitrate", enableDynBitrate); - auto streamOutput = StreamingOutput(); // shadowing is sort of bad, but also convenient + auto streamOutputRef = StreamingOutput(); - obs_output_update(streamOutput, settings); + obs_output_update(streamOutputRef, settings); if (!reconnect) { maxRetries = 0; } - obs_output_set_delay(streamOutput, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); + obs_output_set_delay(streamOutputRef, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); - obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay); + obs_output_set_reconnect_settings(streamOutputRef, maxRetries, retryDelay); if (!multitrackVideo || !multitrackVideoActive) { SetupVodTrack(service); } - if (obs_output_start(streamOutput)) { + if (obs_output_start(streamOutputRef)) { bool dumpStarted = false; if (multitrackVideo && multitrackVideoActive) { dumpStarted = multitrackVideo->StartedStreaming(); @@ -747,7 +747,7 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) multitrackVideoActive = false; } - const char *error = obs_output_get_last_error(streamOutput); + const char *error = obs_output_get_last_error(streamOutputRef); bool hasLastError = error && *error; if (hasLastError) { lastError = error; @@ -755,7 +755,7 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) lastError = string(); } - const char *type = obs_output_get_id(streamOutput); + const char *type = obs_output_get_id(streamOutputRef); blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type, hasLastError ? " Last Error: " : "", hasLastError ? error : ""); return false; @@ -778,7 +778,7 @@ void SimpleOutput::UpdateRecording() if (!ffmpegOutput) { UpdateRecordingSettings(); } - } else if (!obs_output_active(streamOutput)) { + } else if (!obs_output_active(streamOutputRef)) { Update(); } diff --git a/frontend/utility/ThumbnailItem.cpp.hpp b/frontend/utility/ThumbnailItem.cpp.hpp index de259a5a94..9cf46531b8 100644 --- a/frontend/utility/ThumbnailItem.cpp.hpp +++ b/frontend/utility/ThumbnailItem.cpp.hpp @@ -87,9 +87,9 @@ QPixmap ThumbnailItem::getPixmap() const return pixmap; } -void ThumbnailItem::setPixmap(QPixmap pixmap) +void ThumbnailItem::setPixmap(QPixmap newPixmap) { - this->pixmap = std::move(pixmap); + this->pixmap = std::move(newPixmap); emit pixmapUpdated(this->pixmap); } @@ -164,9 +164,9 @@ bool ThumbnailItem::update() return false; } - QPixmap pixmap; + QPixmap blank_pixmap; if (this->pixmap.isNull()) { - this->pixmap = pixmap; + this->pixmap = blank_pixmap; } if (source) { diff --git a/frontend/utility/ThumbnailItem.hpp b/frontend/utility/ThumbnailItem.hpp index 2f4ee50e51..774061e2a7 100644 --- a/frontend/utility/ThumbnailItem.hpp +++ b/frontend/utility/ThumbnailItem.hpp @@ -47,7 +47,7 @@ class ThumbnailItem : public QObject { bool update(); [[nodiscard]] QPixmap getPixmap() const; - void setPixmap(QPixmap pixmap); + void setPixmap(QPixmap newPixmap); [[nodiscard]] bool isDefaultPixmap() const { return isDefaultPixmap_; } [[nodiscard]] bool isValid() const diff --git a/frontend/utility/ThumbnailManager.cpp.hpp b/frontend/utility/ThumbnailManager.cpp.hpp index 33e5a24910..1f7a3a36a9 100644 --- a/frontend/utility/ThumbnailManager.cpp.hpp +++ b/frontend/utility/ThumbnailManager.cpp.hpp @@ -251,9 +251,9 @@ void ThumbnailManager::deleteItemById(const std::string &uuid) QPointer item = entry->second; if (item && !item->isDefaultPixmap()) { - std::string uuid = item->getUuid(); + std::string item_uuid = item->getUuid(); QPixmap pixmap = item->getPixmap(); - addItemToCache(uuid, pixmap); + addItemToCache(item_uuid, pixmap); } thumbnailList.erase(uuid); diff --git a/frontend/utility/ThumbnailView.cpp.hpp b/frontend/utility/ThumbnailView.cpp.hpp index 17a9adf53a..03b7ee4e1d 100644 --- a/frontend/utility/ThumbnailView.cpp.hpp +++ b/frontend/utility/ThumbnailView.cpp.hpp @@ -39,12 +39,12 @@ ThumbnailView::ThumbnailView(QObject *parent, const QPointer &ite } } -void ThumbnailView::setEnabled(bool enabled) +void ThumbnailView::setEnabled(bool newEnabled) { - if (this->enabled != enabled) { - this->enabled = enabled; + if (this->enabled != newEnabled) { + this->enabled = newEnabled; - emit enabledChanged(enabled); + emit enabledChanged(newEnabled); } } @@ -57,9 +57,9 @@ void ThumbnailView::requestUpdate() emit updateRequested(uuid); } -void ThumbnailView::setPixmap(QPixmap pixmap) +void ThumbnailView::setPixmap(QPixmap newPixmap) { - this->pixmap = std::move(pixmap); + this->pixmap = std::move(newPixmap); emit updated(this->pixmap); } diff --git a/frontend/utility/ThumbnailView.hpp b/frontend/utility/ThumbnailView.hpp index 093b364eba..eae013af86 100644 --- a/frontend/utility/ThumbnailView.hpp +++ b/frontend/utility/ThumbnailView.hpp @@ -40,7 +40,7 @@ class ThumbnailView : public QObject { [[nodiscard]] QPixmap getPixmap() const { return pixmap; } [[nodiscard]] bool isEnabled() const { return enabled; } - void setEnabled(bool enabled); + void setEnabled(bool newEnabled); void requestUpdate(); @@ -50,5 +50,5 @@ class ThumbnailView : public QObject { void updateRequested(std::string &uuid); public slots: - void setPixmap(QPixmap pixmap); + void setPixmap(QPixmap newPixmap); }; diff --git a/frontend/utility/audio-encoders.cpp.hpp b/frontend/utility/audio-encoders.cpp.hpp index 96e150362f..10fecfdd0a 100644 --- a/frontend/utility/audio-encoders.cpp.hpp +++ b/frontend/utility/audio-encoders.cpp.hpp @@ -164,12 +164,12 @@ static void PopulateBitrateLists() id); } - ostringstream ss; + ostringstream bitrate_list; for (auto &bitrate : encoderBitrates[encoder]) { - ss << "\n " << setw(3) << bitrate << " kbit/s"; + bitrate_list << "\n " << setw(3) << bitrate << " kbit/s"; } - blog(LOG_DEBUG, "%s (%s) encoder bitrates:%s", EncoderName(id), id, ss.str().c_str()); + blog(LOG_DEBUG, "%s (%s) encoder bitrates:%s", EncoderName(id), id, bitrate_list.str().c_str()); } if (encoderBitrates.empty() && fallbackBitrates.empty()) { From f21914b16bd5a2a9b35bab8d764e4a5013134944 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 16:38:00 -0700 Subject: [PATCH 51/63] build(msvc): keep the member streamOutput in UpdateRecording (#2626) Wave 21's SimpleOutput rename reached one use it should not have: line 781 in UpdateRecording reads the inherited BasicOutputHandler::streamOutput member, not the StartStreaming alias, so the Qt Frontend Linux lane of run 40785707601 failed with "'streamOutputRef' was not declared in this scope". RED: the Qt Frontend Linux job 123159022296 at 494090fa0 (SimpleOutput.cpp.hpp:781:39: error: 'streamOutputRef' was not declared in this scope; did you mean 'streamOutput'?). GREEN: this restores the member read; the only alias that keeps its new name is the local in StartStreaming. --- frontend/utility/SimpleOutput.cpp.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/utility/SimpleOutput.cpp.hpp b/frontend/utility/SimpleOutput.cpp.hpp index dd6f9d7065..58ecc5bd90 100644 --- a/frontend/utility/SimpleOutput.cpp.hpp +++ b/frontend/utility/SimpleOutput.cpp.hpp @@ -778,7 +778,7 @@ void SimpleOutput::UpdateRecording() if (!ffmpegOutput) { UpdateRecordingSettings(); } - } else if (!obs_output_active(streamOutputRef)) { + } else if (!obs_output_active(streamOutput)) { Update(); } From d8ad44d12af57b15da6add9456f27c288403efe0 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 16:45:31 -0700 Subject: [PATCH 52/63] build(msvc): name the widget-layer locals after what they hold (#2626) Wave 22 (part 1), the 14 findings in the small widget files from the /W4 x64 log of 40785697992, all name-hiding at the declaration: three signal lambdas in InitOBSCallbacks and the rest shadowed locals/params. frontend/widgets/OBSBasic.cpp.hpp data x3 -> handler_data OBSBasicStatusBar.cpp.hpp seconds x2 -> secondsPart OBSBasicStatusBar.cpp.hpp/.hpp seconds -> timeoutSeconds OBSBasic_ContextToolbar.cpp.hpp toolbar -> mediaControls OBSBasic_DeviceBusy.cpp.hpp box -> messageBox OBSBasic_Dropfiles.cpp.hpp data -> droppedValue OBSBasic_Projectors.cpp.hpp data -> projectorData OBSBasic_Recording.cpp.hpp remux -> remuxDialog OBSBasic_Service.cpp.hpp data x2 -> serviceData OBSBasic_Streaming.cpp.hpp auth -> currentAuth Renames only; the Dropfiles lambda that receives the saved scene JSON keeps its own name (jsonText) so it does not hide the renamed parameter. The remaining 47 findings of this wave (OBSBasic_Hotkeys 22, OBSBasic_Scenes 12, OBSBasicPreview 7, OBSBasic_SceneCollections 6) come in the next commit. --- frontend/widgets/OBSBasic.cpp.hpp | 12 +++++----- frontend/widgets/OBSBasicStatusBar.cpp.hpp | 12 +++++----- frontend/widgets/OBSBasicStatusBar.hpp | 2 +- .../widgets/OBSBasic_ContextToolbar.cpp.hpp | 4 ++-- frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp | 18 +++++++------- frontend/widgets/OBSBasic_Dropfiles.cpp.hpp | 24 +++++++++---------- frontend/widgets/OBSBasic_Projectors.cpp.hpp | 14 +++++------ frontend/widgets/OBSBasic_Recording.cpp.hpp | 6 ++--- frontend/widgets/OBSBasic_Service.cpp.hpp | 22 ++++++++--------- frontend/widgets/OBSBasic_Streaming.cpp.hpp | 9 +++---- 10 files changed, 62 insertions(+), 61 deletions(-) diff --git a/frontend/widgets/OBSBasic.cpp.hpp b/frontend/widgets/OBSBasic.cpp.hpp index e34f5f649f..caab64c751 100644 --- a/frontend/widgets/OBSBasic.cpp.hpp +++ b/frontend/widgets/OBSBasic.cpp.hpp @@ -775,22 +775,22 @@ void OBSBasic::InitOBSCallbacks() signalHandlers.emplace_back(obs_get_signal_handler(), "source_device_busy", OBSBasic::SourceDeviceBusy, this); signalHandlers.emplace_back( obs_get_signal_handler(), "hotkey_background_status_changed", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::NotifyHotkeyBackgroundStatus, Qt::QueuedConnection); }, this); signalHandlers.emplace_back( obs_get_signal_handler(), "source_filter_add", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::UpdateEditMenu, + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::UpdateEditMenu, Qt::QueuedConnection); }, this); signalHandlers.emplace_back( obs_get_signal_handler(), "source_filter_remove", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::UpdateEditMenu, + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::UpdateEditMenu, Qt::QueuedConnection); }, this); diff --git a/frontend/widgets/OBSBasicStatusBar.cpp.hpp b/frontend/widgets/OBSBasicStatusBar.cpp.hpp index 4d1df02def..8da68b2f7d 100644 --- a/frontend/widgets/OBSBasicStatusBar.cpp.hpp +++ b/frontend/widgets/OBSBasicStatusBar.cpp.hpp @@ -255,12 +255,12 @@ void OBSBasicStatusBar::UpdateStreamTime() { totalStreamSeconds++; - int seconds = totalStreamSeconds % 60; + int secondsPart = totalStreamSeconds % 60; int totalMinutes = totalStreamSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds); + QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, secondsPart); statusWidget->ui->streamTime->setText(text); if (streamOutput && !statusWidget->ui->streamTime->isEnabled()) { statusWidget->ui->streamTime->setDisabled(false); @@ -315,12 +315,12 @@ void OBSBasicStatusBar::UpdateRecordTime() void OBSBasicStatusBar::UpdateRecordTimeLabel() { - int seconds = totalRecordSeconds % 60; + int secondsPart = totalRecordSeconds % 60; int totalMinutes = totalRecordSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds); + QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, secondsPart); if (os_atomic_load_bool(&recording_paused)) { text += QStringLiteral(" (PAUSED)"); } @@ -415,7 +415,7 @@ void OBSBasicStatusBar::OBSOutputReconnectSuccess(void *data, calldata_t *) QMetaObject::invokeMethod(statusBar, &OBSBasicStatusBar::ReconnectSuccess); } -void OBSBasicStatusBar::Reconnect(int seconds) +void OBSBasicStatusBar::Reconnect(int timeoutSeconds) { OBSBasic *main = qobject_cast(parent()); @@ -423,7 +423,7 @@ void OBSBasicStatusBar::Reconnect(int seconds) main->SysTrayNotify(QTStr("Basic.SystemTray.Message.Reconnecting"), QSystemTrayIcon::Warning); } - reconnectTimeout = seconds; + reconnectTimeout = timeoutSeconds; if (streamOutput) { OBSOutput output = OBSGetStrongRef(streamOutput); diff --git a/frontend/widgets/OBSBasicStatusBar.hpp b/frontend/widgets/OBSBasicStatusBar.hpp index 3fefa1cb52..9dac06230f 100644 --- a/frontend/widgets/OBSBasicStatusBar.hpp +++ b/frontend/widgets/OBSBasicStatusBar.hpp @@ -89,7 +89,7 @@ public slots: void showMessage(const QString &message, int timeout = 0); private slots: - void Reconnect(int seconds); + void Reconnect(int timeoutSeconds); void ReconnectSuccess(); void UpdateStatusBar(); void UpdateCurrentFPS(); diff --git a/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp b/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp index 60fee3d6b5..9dbd819ef2 100644 --- a/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp +++ b/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp @@ -208,8 +208,8 @@ void OBSBasic::UpdateContextBar(bool force) if (toolbar->GetSource() == source) { updateNeeded = false; } - } else if (MediaControls *toolbar = dynamic_cast(la->widget())) { - if (toolbar->GetSource() == source) { + } else if (MediaControls *mediaControls = dynamic_cast(la->widget())) { + if (mediaControls->GetSource() == source) { updateNeeded = false; } } diff --git a/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp b/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp index cc1f2fe926..d11410e346 100644 --- a/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp +++ b/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp @@ -67,22 +67,22 @@ void OBSBasic::ShowDeviceBusy(OBSWeakSource weak, QString device, QString holder (canForce ? QTStr("Basic.DeviceBusy.ForceExplain").arg(holder) : QTStr("Basic.DeviceBusy.Wait")); source = nullptr; - QMessageBox box(this); - box.setIcon(QMessageBox::Warning); - box.setWindowTitle(QTStr("Basic.DeviceBusy.Title")); - box.setText(text); - QPushButton *force = canForce ? box.addButton(QTStr("Basic.DeviceBusy.Force"), QMessageBox::AcceptRole) + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Warning); + messageBox.setWindowTitle(QTStr("Basic.DeviceBusy.Title")); + messageBox.setText(text); + QPushButton *force = canForce ? messageBox.addButton(QTStr("Basic.DeviceBusy.Force"), QMessageBox::AcceptRole) : nullptr; - box.addButton(canForce ? QMessageBox::Cancel : QMessageBox::Ok); + messageBox.addButton(canForce ? QMessageBox::Cancel : QMessageBox::Ok); if (force) { - box.setDefaultButton(force); + messageBox.setDefaultButton(force); } busyDevicePopups.insert(device); - box.exec(); + messageBox.exec(); busyDevicePopups.remove(device); - if (!force || box.clickedButton() != force) { + if (!force || messageBox.clickedButton() != force) { return; } diff --git a/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp b/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp index cfdba8a266..95b3266d60 100644 --- a/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp +++ b/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp @@ -100,7 +100,7 @@ void OBSBasic::AddDropURL(QUrl url, QString &name, obs_data_t *settings, const o obs_data_set_string(settings, "url", QT_TO_UTF8(url.url())); } -void OBSBasic::AddDropSource(const char *data, DropType image) +void OBSBasic::AddDropSource(const char *droppedValue, DropType image) { OBSBasic *main = OBSBasic::Get(); OBSDataAutoRelease settings = obs_data_create(); @@ -112,33 +112,33 @@ void OBSBasic::AddDropSource(const char *data, DropType image) switch (image) { case DropType_RawText: - obs_data_set_string(settings, "text", data); + obs_data_set_string(settings, "text", droppedValue); type = GetPlatformTextSourceId(); break; case DropType_Text: - SetPlatformTextFileSettings(settings, data, name); + SetPlatformTextFileSettings(settings, droppedValue, name); type = GetPlatformTextSourceId(); break; case DropType_Image: - obs_data_set_string(settings, "file", data); - name = QUrl::fromLocalFile(QString(data)).fileName(); + obs_data_set_string(settings, "file", droppedValue); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "image_source"; break; case DropType_Media: - obs_data_set_string(settings, "local_file", data); - name = QUrl::fromLocalFile(QString(data)).fileName(); + obs_data_set_string(settings, "local_file", droppedValue); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "ffmpeg_source"; break; case DropType_Html: obs_data_set_bool(settings, "is_local_file", true); - obs_data_set_string(settings, "local_file", data); + obs_data_set_string(settings, "local_file", droppedValue); obs_data_set_int(settings, "width", ovi.base_width); obs_data_set_int(settings, "height", ovi.base_height); - name = QUrl::fromLocalFile(QString(data)).fileName(); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "browser_source"; break; case DropType_Url: - AddDropURL(QUrl(data), name, settings, ovi); + AddDropURL(QUrl(droppedValue), name, settings, ovi); type = "browser_source"; break; } @@ -167,11 +167,11 @@ void OBSBasic::AddDropSource(const char *data, DropType image) OBSSourceAutoRelease scene = obs_get_source_by_uuid(sceneUUID.c_str()); OBSBasic::Get()->SetCurrentScene(scene.Get(), true); }; - auto redo = [sceneUUID, sourceName, type](const std::string &data) { + auto redo = [sceneUUID, sourceName, type](const std::string &jsonText) { OBSSourceAutoRelease scene = obs_get_source_by_uuid(sceneUUID.c_str()); OBSBasic::Get()->SetCurrentScene(scene.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(jsonText.c_str()); OBSSourceAutoRelease source = obs_load_source(dat); obs_scene_add(obs_scene_from_source(scene), source.Get()); }; diff --git a/frontend/widgets/OBSBasic_Projectors.cpp.hpp b/frontend/widgets/OBSBasic_Projectors.cpp.hpp index e7c042dc66..2aa03f10e7 100644 --- a/frontend/widgets/OBSBasic_Projectors.cpp.hpp +++ b/frontend/widgets/OBSBasic_Projectors.cpp.hpp @@ -68,15 +68,15 @@ void OBSBasic::LoadSavedProjectors(obs_data_array_t *array) size_t num = obs_data_array_count(array); for (size_t i = 0; i < num; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); + OBSDataAutoRelease projectorData = obs_data_array_item(array, i); SavedProjectorInfo info = {}; - info.monitor = obs_data_get_int(data, "monitor"); - info.type = static_cast(obs_data_get_int(data, "type")); - info.geometry = std::string(obs_data_get_string(data, "geometry")); - info.name = std::string(obs_data_get_string(data, "name")); - info.alwaysOnTop = obs_data_get_bool(data, "alwaysOnTop"); - info.alwaysOnTopOverridden = obs_data_get_bool(data, "alwaysOnTopOverridden"); + info.monitor = obs_data_get_int(projectorData, "monitor"); + info.type = static_cast(obs_data_get_int(projectorData, "type")); + info.geometry = std::string(obs_data_get_string(projectorData, "geometry")); + info.name = std::string(obs_data_get_string(projectorData, "name")); + info.alwaysOnTop = obs_data_get_bool(projectorData, "alwaysOnTop"); + info.alwaysOnTopOverridden = obs_data_get_bool(projectorData, "alwaysOnTopOverridden"); OpenSavedProjector(&info); } diff --git a/frontend/widgets/OBSBasic_Recording.cpp.hpp b/frontend/widgets/OBSBasic_Recording.cpp.hpp index 5bdc086b7e..b60dc72e55 100644 --- a/frontend/widgets/OBSBasic_Recording.cpp.hpp +++ b/frontend/widgets/OBSBasic_Recording.cpp.hpp @@ -95,11 +95,11 @@ void OBSBasic::AutoRemux(QString input, bool no_show) output += "mp4"; } - OBSRemux *remux = new OBSRemux(QT_TO_UTF8(path), this, true); + OBSRemux *remuxDialog = new OBSRemux(QT_TO_UTF8(path), this, true); if (!no_show) { - remux->show(); + remuxDialog->show(); } - remux->AutoRemux(input, output); + remuxDialog->AutoRemux(input, output); } void OBSBasic::StartRecording() diff --git a/frontend/widgets/OBSBasic_Service.cpp.hpp b/frontend/widgets/OBSBasic_Service.cpp.hpp index 1448af85ab..c229c155e0 100644 --- a/frontend/widgets/OBSBasic_Service.cpp.hpp +++ b/frontend/widgets/OBSBasic_Service.cpp.hpp @@ -31,20 +31,20 @@ void OBSBasic::SaveService() const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(OBSServiceFileName); - OBSDataAutoRelease data = obs_data_create(); + OBSDataAutoRelease serviceData = obs_data_create(); OBSDataAutoRelease settings = obs_service_get_settings(service); - obs_data_set_string(data, "type", obs_service_get_type(service)); - obs_data_set_obj(data, "settings", settings); + obs_data_set_string(serviceData, "type", obs_service_get_type(service)); + obs_data_set_obj(serviceData, "settings", settings); - if (!obs_data_save_json_safe(data, jsonFilePath.u8string().c_str(), "tmp", "bak")) { + if (!obs_data_save_json_safe(serviceData, jsonFilePath.u8string().c_str(), "tmp", "bak")) { blog(LOG_WARNING, "Failed to save service"); } } bool OBSBasic::LoadService() { - OBSDataAutoRelease data; + OBSDataAutoRelease serviceData; try { const OBSProfile ¤tProfile = GetCurrentProfile(); @@ -52,9 +52,9 @@ bool OBSBasic::LoadService() const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(OBSServiceFileName); - data = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); + serviceData = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - if (!data) { + if (!serviceData) { return false; } } catch (const std::invalid_argument &error) { @@ -63,11 +63,11 @@ bool OBSBasic::LoadService() } const char *type; - obs_data_set_default_string(data, "type", "rtmp_common"); - type = obs_data_get_string(data, "type"); + obs_data_set_default_string(serviceData, "type", "rtmp_common"); + type = obs_data_get_string(serviceData, "type"); - OBSDataAutoRelease settings = obs_data_get_obj(data, "settings"); - OBSDataAutoRelease hotkey_data = obs_data_get_obj(data, "hotkeys"); + OBSDataAutoRelease settings = obs_data_get_obj(serviceData, "settings"); + OBSDataAutoRelease hotkey_data = obs_data_get_obj(serviceData, "hotkeys"); service = obs_service_create(type, "default_service", settings, hotkey_data); obs_service_release(service); diff --git a/frontend/widgets/OBSBasic_Streaming.cpp.hpp b/frontend/widgets/OBSBasic_Streaming.cpp.hpp index d3fd8ffdfb..3032026213 100644 --- a/frontend/widgets/OBSBasic_Streaming.cpp.hpp +++ b/frontend/widgets/OBSBasic_Streaming.cpp.hpp @@ -418,10 +418,11 @@ void OBSBasic::StreamActionTriggered() return; } - Auth *auth = GetAuth(); + Auth *currentAuth = GetAuth(); - auto action = (auth && auth->external()) ? StreamSettingsAction::ContinueStream - : UIValidation::StreamSettingsConfirmation(this, service); + auto action = (currentAuth && currentAuth->external()) + ? StreamSettingsAction::ContinueStream + : UIValidation::StreamSettingsConfirmation(this, service); switch (action) { case StreamSettingsAction::ContinueStream: break; @@ -440,7 +441,7 @@ void OBSBasic::StreamActionTriggered() OBSDataAutoRelease settings = obs_service_get_settings(service); bwtest = obs_data_get_bool(settings, "bwtest"); // Disable confirmation if this is going to open broadcast setup - if (auth && auth->broadcastFlow() && !broadcastReady && !broadcastActive) { + if (currentAuth && currentAuth->broadcastFlow() && !broadcastReady && !broadcastActive) { confirm = false; } } From 39cf1a8d50a224bbfb5e9d60d55116cfecbb9345 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 17:22:16 -0700 Subject: [PATCH 53/63] build(msvc): name the hotkey and undo params at their declarations (#2626) Wave 22 (part 2): the remaining 47 name-hiding findings from the wave-21 x64 app build (run 40789602679, "Build windows x64"), all at the declaration. Every rename is local to one lambda/local scope; no behaviour changes. frontend/widgets/OBSBasic_Hotkeys.cpp.hpp MAKE_CALLBACK macro parameter + six hotkey lambdas data x22 -> handler_data frontend/widgets/OBSBasic_Scenes.cpp.hpp SaveSceneListOrder / LoadSceneListOrder data -> orderData / itemData AddScene: hotkey lambda data -> handler_data AddScene: scene source local source -> sceneSource DuplicateSelectedScene: existing source source -> existingSource DuplicateSelectedScene: undo/redo params data -> sceneName RemoveSelectedScene: undo payload data -> undoData context menu: private settings data -> privateSettings on_actionAddScene_triggered source -> existingSource, data x2 -> sceneName frontend/widgets/OBSBasicPreview.cpp.hpp GetStretchHandleData / mousePressEvent / BoxItems / DrawSpacingHelpers data x11 -> findData mouseReleaseEvent: undo payload data -> jsonStr BoxItems parameter (hides the member) startPos -> boxStart mouseMoveEvent: OBSBasic pointer main -> obsBasic frontend/widgets/OBSBasic_SceneCollections.cpp.hpp two obs_data_array_enum callbacks data -> sourceData obs_save_sources_filtered / obs_enum_all_sources callback data -> handler_data Load: collection file data data -> collectionData LoadData: the whole parameter data -> collectionData frontend/widgets/OBSBasic.hpp, OBSBasicPreview.hpp parameter names kept in step with the definitions above. Refs #2626, Refs #516. --- frontend/widgets/OBSBasic.hpp | 2 +- frontend/widgets/OBSBasicPreview.cpp.hpp | 50 +++++----- frontend/widgets/OBSBasicPreview.hpp | 2 +- frontend/widgets/OBSBasic_Hotkeys.cpp.hpp | 30 +++--- .../widgets/OBSBasic_SceneCollections.cpp.hpp | 97 ++++++++++--------- frontend/widgets/OBSBasic_Scenes.cpp.hpp | 72 +++++++------- 6 files changed, 128 insertions(+), 125 deletions(-) diff --git a/frontend/widgets/OBSBasic.hpp b/frontend/widgets/OBSBasic.hpp index bd93e92afb..6f324cd34e 100644 --- a/frontend/widgets/OBSBasic.hpp +++ b/frontend/widgets/OBSBasic.hpp @@ -1120,7 +1120,7 @@ private slots: void DisableRelativeCoordinates(bool disable); void CreateDefaultScene(bool firstStart); void Save(SceneCollection &collection); - void LoadData(obs_data_t *data, SceneCollection &collection); + void LoadData(obs_data_t *collectionData, SceneCollection &collection); void Load(SceneCollection &collection); void ClearSceneData(); diff --git a/frontend/widgets/OBSBasicPreview.cpp.hpp b/frontend/widgets/OBSBasicPreview.cpp.hpp index c2a627cbf9..badb86abf5 100644 --- a/frontend/widgets/OBSBasicPreview.cpp.hpp +++ b/frontend/widgets/OBSBasicPreview.cpp.hpp @@ -508,15 +508,15 @@ void OBSBasicPreview::GetStretchHandleData(const vec2 &pos, bool ignoreGroup) float scale = main->previewScale / main->GetDevicePixelRatio(); vec2 scaled_pos = pos; vec2_divf(&scaled_pos, &scaled_pos, scale); - HandleFindData data(scaled_pos, scale); - obs_scene_enum_items(scene, FindHandleAtPos, &data); + HandleFindData findData(scaled_pos, scale); + obs_scene_enum_items(scene, FindHandleAtPos, &findData); - stretchItem = std::move(data.item); - stretchHandle = data.handle; + stretchItem = std::move(findData.item); + stretchHandle = findData.handle; - rotateAngle = data.angle; - rotatePoint = data.rotatePoint; - offsetPoint = data.offsetPoint; + rotateAngle = findData.angle; + rotatePoint = findData.rotatePoint; + offsetPoint = findData.offsetPoint; if (stretchHandle != ItemHandle::None) { matrix4 boxTransform; @@ -657,12 +657,12 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event) if (altDown || shiftDown || ctrlDown) { vec2 s; - SceneFindBoxData data(s, s); + SceneFindBoxData findData(s, s); - obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &data); + obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &findData); std::lock_guard lock(selectMutex); - selectedItems = data.sceneItems; + selectedItems = findData.sceneItems; } vec2_set(&startPos, x, y); @@ -859,12 +859,12 @@ void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event) OBSDataAutoRelease rwrapper = obs_scene_save_transform_states(main->GetCurrentScene(), true); - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &jsonStr) { + OBSDataAutoRelease dat = obs_data_create_from_json(jsonStr.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid")); OBSBasic::Get()->SetCurrentScene(source.Get(), true); - obs_scene_load_transform_states(data.c_str()); + obs_scene_load_transform_states(jsonStr.c_str()); }; if (wrapper && rwrapper) { @@ -1308,7 +1308,7 @@ static bool FindItemsInBox(obs_scene_t * /* scene */, obs_sceneitem_t *item, voi return true; } -void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos) +void OBSBasicPreview::BoxItems(const vec2 &boxStart, const vec2 &pos) { OBSBasic *main = OBSBasic::Get(); @@ -1321,11 +1321,11 @@ void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos) setCursor(Qt::CrossCursor); } - SceneFindBoxData data(startPos, pos); - obs_scene_enum_items(scene, FindItemsInBox, &data); + SceneFindBoxData findData(boxStart, pos); + obs_scene_enum_items(scene, FindItemsInBox, &findData); std::lock_guard lock(selectMutex); - hoveredPreviewItems = data.sceneItems; + hoveredPreviewItems = findData.sceneItems; } vec3 OBSBasicPreview::CalculateStretchPos(const vec3 &tl, const vec3 &br) @@ -1797,10 +1797,10 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) if (!mouseMoved && hoveredPreviewItems.size() > 0) { mousePos = pos; - OBSBasic *main = OBSBasic::Get(); - float scale = main->GetDevicePixelRatio(); - float x = qtPos.x() - main->previewX / scale; - float y = qtPos.y() - main->previewY / scale; + OBSBasic *obsBasic = OBSBasic::Get(); + float scale = obsBasic->GetDevicePixelRatio(); + float x = qtPos.x() - obsBasic->previewX / scale; + float y = qtPos.y() - obsBasic->previewY / scale; vec2_set(&startPos, x, y); updateCursor = true; } @@ -2640,16 +2640,16 @@ void OBSBasicPreview::DrawSpacingHelpers() OBSBasic *main = OBSBasic::Get(); vec2 s; - SceneFindBoxData data(s, s); + SceneFindBoxData findData(s, s); OBSScene scene = main->GetCurrentScene(); - obs_scene_enum_items(scene, FindSelected, &data); + obs_scene_enum_items(scene, FindSelected, &findData); - if (data.sceneItems.size() != 1) { + if (findData.sceneItems.size() != 1) { return; } - OBSSceneItem item = data.sceneItems[0]; + OBSSceneItem item = findData.sceneItems[0]; if (!item) { return; } diff --git a/frontend/widgets/OBSBasicPreview.hpp b/frontend/widgets/OBSBasicPreview.hpp index ff86d41d5c..f52d0acbd0 100644 --- a/frontend/widgets/OBSBasicPreview.hpp +++ b/frontend/widgets/OBSBasicPreview.hpp @@ -123,7 +123,7 @@ class OBSBasicPreview : public OBSQTDisplay { static void SnapItemMovement(vec2 &offset); void MoveItems(const vec2 &pos); - void BoxItems(const vec2 &startPos, const vec2 &pos); + void BoxItems(const vec2 &boxStart, const vec2 &pos); void ProcessClick(const vec2 &pos); diff --git a/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp b/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp index bb7482b1a7..8467ff8c51 100644 --- a/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp +++ b/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp @@ -179,8 +179,8 @@ void OBSBasic::CreateHotkeys() }; #define MAKE_CALLBACK(pred, method, log_action) \ - [](void *data, obs_hotkey_pair_id, obs_hotkey_t *, bool pressed) { \ - OBSBasic &basic = *static_cast(data); \ + [](void *handler_data, obs_hotkey_pair_id, obs_hotkey_t *, bool pressed) { \ + OBSBasic &basic = *static_cast(handler_data); \ if ((pred) && pressed) { \ blog(LOG_INFO, log_action " due to hotkey"); \ method(); \ @@ -199,8 +199,8 @@ void OBSBasic::CreateHotkeys() this, this); LoadHotkeyPair(streamingHotkeys, "OBSBasic.StartStreaming", "OBSBasic.StopStreaming"); - auto cb = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - OBSBasic &basic = *static_cast(data); + auto cb = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + OBSBasic &basic = *static_cast(handler_data); if (basic.outputHandler->StreamingActive() && pressed) { basic.ForceStopStreaming(); } @@ -260,8 +260,8 @@ void OBSBasic::CreateHotkeys() this, this); LoadHotkeyPair(replayBufHotkeys, "OBSBasic.StartReplayBuffer", "OBSBasic.StopReplayBuffer"); - auto replayBufferCallback = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - OBSBasic *basic = static_cast(data); + auto replayBufferCallback = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + OBSBasic *basic = static_cast(handler_data); if (basic->outputHandler->ReplayBufferActive() && pressed) { blog(LOG_INFO, "Saving replay buffer due to hotkey"); basic->ReplayBufferSave(); @@ -324,9 +324,9 @@ void OBSBasic::CreateHotkeys() LoadHotkeyPair(contextBarHotkeys, "OBSBasic.ShowContextBar", "OBSBasic.HideContextBar"); #undef MAKE_CALLBACK - auto transition = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto transition = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::TransitionClicked, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::TransitionClicked, Qt::QueuedConnection); } }; @@ -334,9 +334,9 @@ void OBSBasic::CreateHotkeys() transitionHotkey = obs_hotkey_register_frontend("OBSBasic.Transition", Str("Transition"), transition, this); LoadHotkey(transitionHotkey, "OBSBasic.Transition"); - auto resetStats = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto resetStats = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::ResetStatsHotkey, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::ResetStatsHotkey, Qt::QueuedConnection); } }; @@ -345,9 +345,9 @@ void OBSBasic::CreateHotkeys() obs_hotkey_register_frontend("OBSBasic.ResetStats", Str("Basic.Stats.ResetStats"), resetStats, this); LoadHotkey(statsHotkey, "OBSBasic.ResetStats"); - auto screenshot = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto screenshot = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::Screenshot, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::Screenshot, Qt::QueuedConnection, nullptr); } }; @@ -355,10 +355,10 @@ void OBSBasic::CreateHotkeys() screenshotHotkey = obs_hotkey_register_frontend("OBSBasic.Screenshot", Str("Screenshot"), screenshot, this); LoadHotkey(screenshotHotkey, "OBSBasic.Screenshot"); - auto screenshotSource = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto screenshotSource = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::ScreenshotSelectedSource, - Qt::QueuedConnection); + QMetaObject::invokeMethod(static_cast(handler_data), + &OBSBasic::ScreenshotSelectedSource, Qt::QueuedConnection); } }; diff --git a/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp b/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp index 50a01db52c..f33dfab9ad 100644 --- a/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp +++ b/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp @@ -170,10 +170,10 @@ void OBSBasic::SetupDuplicateSceneCollection(const std::string &collectionName) obs_data_array_enum( sources, - [](obs_data_t *data, void *) -> void { + [](obs_data_t *sourceData, void *) -> void { const char *uuid = os_generate_uuid(); - obs_data_set_string(data, "uuid", uuid); + obs_data_set_string(sourceData, "uuid", uuid); bfree((void *)uuid); }, @@ -660,9 +660,9 @@ void OBSBasic::on_actionExportSceneCollection_triggered() OBSDataVector sourceItems; obs_data_array_enum( sources, - [](obs_data_t *data, void *vector) -> void { + [](obs_data_t *sourceData, void *vector) -> void { OBSDataVector &sourceItems{*static_cast(vector)}; - sourceItems.push_back(data); + sourceItems.push_back(sourceData); }, &sourceItems); @@ -831,8 +831,8 @@ void OBSBasic::Save(SceneCollection &collection) using FilterAudioSources_t = decltype(FilterAudioSources); OBSDataArrayAutoRelease sourcesArray = obs_save_sources_filtered( - [](void *data, obs_source_t *source) { - auto &func = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &func = *static_cast(handler_data); return func(source); }, static_cast(&FilterAudioSources)); @@ -1121,9 +1121,9 @@ void OBSBasic::Load(SceneCollection &collection) lastOutputResolution.reset(); collection.setMigrationResolution(0, 0); - obs_data_t *data = obs_data_create_from_json_file_safe(collection.getFilePathString().c_str(), "bak"); + obs_data_t *collectionData = obs_data_create_from_json_file_safe(collection.getFilePathString().c_str(), "bak"); - if (!data) { + if (!collectionData) { disableSaving--; const std::filesystem::path filePath = collection.getFilePath(); @@ -1152,10 +1152,10 @@ void OBSBasic::Load(SceneCollection &collection) return; } - LoadData(data, collection); + LoadData(collectionData, collection); } -void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) +void OBSBasic::LoadData(obs_data_t *collectionData, SceneCollection &collection) { ClearSceneData(); ClearContextBar(); @@ -1176,23 +1176,23 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) QApplication::sendPostedEvents(nullptr); - OBSDataAutoRelease modulesObj = obs_data_get_obj(data, "modules"); + OBSDataAutoRelease modulesObj = obs_data_get_obj(collectionData, "modules"); if (api) { api->on_preload(modulesObj); } /* Keep a reference to "modules" data so plugins that are not loaded do * not have their collection specific data lost. */ - collectionModuleData = obs_data_get_obj(data, "modules"); + collectionModuleData = obs_data_get_obj(collectionData, "modules"); - OBSDataArrayAutoRelease sceneOrder = obs_data_get_array(data, "scene_order"); - OBSDataArrayAutoRelease sources = obs_data_get_array(data, "sources"); - OBSDataArrayAutoRelease groups = obs_data_get_array(data, "groups"); - OBSDataArrayAutoRelease transitionsData = obs_data_get_array(data, "transitions"); - OBSDataArrayAutoRelease collection_canvases = obs_data_get_array(data, "canvases"); - const char *sceneName = obs_data_get_string(data, "current_scene"); - const char *programSceneName = obs_data_get_string(data, "current_program_scene"); - const char *transitionName = obs_data_get_string(data, "current_transition"); + OBSDataArrayAutoRelease sceneOrder = obs_data_get_array(collectionData, "scene_order"); + OBSDataArrayAutoRelease sources = obs_data_get_array(collectionData, "sources"); + OBSDataArrayAutoRelease groups = obs_data_get_array(collectionData, "groups"); + OBSDataArrayAutoRelease transitionsData = obs_data_get_array(collectionData, "transitions"); + OBSDataArrayAutoRelease collection_canvases = obs_data_get_array(collectionData, "canvases"); + const char *sceneName = obs_data_get_string(collectionData, "current_scene"); + const char *programSceneName = obs_data_get_string(collectionData, "current_program_scene"); + const char *transitionName = obs_data_get_string(collectionData, "current_transition"); if (!opt_starting_scene.empty()) { programSceneName = opt_starting_scene.c_str(); @@ -1201,7 +1201,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) } } - int newDuration = obs_data_get_int(data, "transition_duration"); + int newDuration = obs_data_get_int(collectionData, "transition_duration"); if (!newDuration) { newDuration = 300; } @@ -1212,9 +1212,9 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) const char *curSceneCollection = config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection"); - obs_data_set_default_string(data, "name", curSceneCollection); + obs_data_set_default_string(collectionData, "name", curSceneCollection); - const char *name = obs_data_get_string(data, "name"); + const char *name = obs_data_get_string(collectionData, "name"); OBSSourceAutoRelease curScene; OBSSourceAutoRelease curProgramScene; obs_source_t *curTransition; @@ -1223,12 +1223,12 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) name = curSceneCollection; } - LoadAudioDevice(DESKTOP_AUDIO_1.data(), 1, data); - LoadAudioDevice(DESKTOP_AUDIO_2.data(), 2, data); - LoadAudioDevice(AUX_AUDIO_1.data(), 3, data); - LoadAudioDevice(AUX_AUDIO_2.data(), 4, data); - LoadAudioDevice(AUX_AUDIO_3.data(), 5, data); - LoadAudioDevice(AUX_AUDIO_4.data(), 6, data); + LoadAudioDevice(DESKTOP_AUDIO_1.data(), 1, collectionData); + LoadAudioDevice(DESKTOP_AUDIO_2.data(), 2, collectionData); + LoadAudioDevice(AUX_AUDIO_1.data(), 3, collectionData); + LoadAudioDevice(AUX_AUDIO_2.data(), 4, collectionData); + LoadAudioDevice(AUX_AUDIO_3.data(), 5, collectionData); + LoadAudioDevice(AUX_AUDIO_4.data(), 6, collectionData); if (collection_canvases) { canvases = OBS::Canvas::LoadCanvases(collection_canvases); @@ -1243,8 +1243,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) bool resetVideo = false; obs_video_info ovi; - int64_t version = obs_data_get_int(data, "version"); - OBSDataAutoRelease res = obs_data_get_obj(data, "resolution"); + int64_t version = obs_data_get_int(collectionData, "version"); + OBSDataAutoRelease res = obs_data_get_obj(collectionData, "resolution"); OBS::Rect collectionSize{}; @@ -1279,8 +1279,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) backupFilePath.replace_extension(".json.v1"); if (!std::filesystem::exists(backupFilePath)) { - bool success = obs_data_save_json_pretty_safe(data, backupFilePath.u8string().c_str(), - "tmp", nullptr); + bool success = obs_data_save_json_pretty_safe( + collectionData, backupFilePath.u8string().c_str(), "tmp", nullptr); if (!success) { blog(LOG_WARNING, @@ -1292,7 +1292,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) } else if (version < 2) { collection.setCoordinateMode(SceneCoordinateMode::Absolute); } else { - OBSDataAutoRelease migrationResolution = obs_data_get_obj(data, "migration_resolution"); + OBSDataAutoRelease migrationResolution = obs_data_get_obj(collectionData, "migration_resolution"); if (migrationResolution) { collection.setMigrationResolution(obs_data_get_int(migrationResolution, "x"), @@ -1335,7 +1335,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) LoadSceneListOrder(sceneOrder); } - curTransition = FindSavedTransition(transitionName, obs_data_get_string(data, "current_transition_id")); + curTransition = + FindSavedTransition(transitionName, obs_data_get_string(collectionData, "current_transition_id")); SetTransitionDuration(newDuration); SetTransition(curTransition); @@ -1347,8 +1348,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) /* if the starting scene command line parameter is bad at all, * fall back to original settings */ if (!opt_starting_scene.empty() && (!curScene || !curProgramScene)) { - sceneName = obs_data_get_string(data, "current_scene"); - programSceneName = obs_data_get_string(data, "current_program_scene"); + sceneName = obs_data_get_string(collectionData, "current_scene"); + programSceneName = obs_data_get_string(collectionData, "current_program_scene"); opt_starting_scene.clear(); goto retryScene; } @@ -1375,7 +1376,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) bool projectorSave = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SaveProjectors"); if (projectorSave) { - OBSDataArrayAutoRelease savedProjectors = obs_data_get_array(data, "saved_projectors"); + OBSDataArrayAutoRelease savedProjectors = obs_data_get_array(collectionData, "saved_projectors"); if (savedProjectors) { LoadSavedProjectors(savedProjectors); @@ -1388,21 +1389,21 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) config_set_string(App()->GetUserConfig(), "Basic", "SceneCollection", collection.getName().c_str()); config_set_string(App()->GetUserConfig(), "Basic", "SceneCollectionFile", collection.getFileName().c_str()); - OBSDataArrayAutoRelease quickTransitionData = obs_data_get_array(data, "quick_transitions"); + OBSDataArrayAutoRelease quickTransitionData = obs_data_get_array(collectionData, "quick_transitions"); LoadQuickTransitions(quickTransitionData); RefreshQuickTransitions(); - bool previewLocked = obs_data_get_bool(data, "preview_locked"); + bool previewLocked = obs_data_get_bool(collectionData, "preview_locked"); ui->preview->SetLocked(previewLocked); ui->actionLockPreview->setChecked(previewLocked); /* ---------------------- */ - bool fixedScaling = obs_data_get_bool(data, "scaling_enabled"); - int scalingLevel = (int)obs_data_get_int(data, "scaling_level"); - float scrollOffX = (float)obs_data_get_double(data, "scaling_off_x"); - float scrollOffY = (float)obs_data_get_double(data, "scaling_off_y"); + bool fixedScaling = obs_data_get_bool(collectionData, "scaling_enabled"); + int scalingLevel = (int)obs_data_get_int(collectionData, "scaling_level"); + float scrollOffX = (float)obs_data_get_double(collectionData, "scaling_off_x"); + float scrollOffY = (float)obs_data_get_double(collectionData, "scaling_off_y"); if (fixedScaling) { ui->preview->SetScalingLevel(scalingLevel); @@ -1413,7 +1414,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) emit ui->preview->DisplayResized(); if (vcamEnabled) { - OBSDataAutoRelease obj = obs_data_get_obj(data, "virtual-camera"); + OBSDataAutoRelease obj = obs_data_get_obj(collectionData, "virtual-camera"); vcamConfig.type = (VCamOutputType)obs_data_get_int(obj, "type2"); if (vcamConfig.type == VCamOutputType::Invalid) { @@ -1446,7 +1447,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) api->on_load(modulesObj); } - obs_data_release(data); + obs_data_release(collectionData); if (!opt_starting_scene.empty()) { opt_starting_scene.clear(); @@ -1716,8 +1717,8 @@ void OBSBasic::on_actionShowMissingFiles_triggered() { obs_missing_files_t *files = obs_missing_files_create(); - auto cb_sources = [](void *data, obs_source_t *source) { - missing_files_list_add_source(data, source); + auto cb_sources = [](void *handler_data, obs_source_t *source) { + missing_files_list_add_source(handler_data, source); return true; }; diff --git a/frontend/widgets/OBSBasic_Scenes.cpp.hpp b/frontend/widgets/OBSBasic_Scenes.cpp.hpp index c1f0873b27..6520bb3f15 100644 --- a/frontend/widgets/OBSBasic_Scenes.cpp.hpp +++ b/frontend/widgets/OBSBasic_Scenes.cpp.hpp @@ -52,9 +52,9 @@ obs_data_array_t *OBSBasic::SaveSceneListOrder() obs_data_array_t *sceneOrder = obs_data_array_create(); for (int i = 0; i < ui->scenes->count(); i++) { - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_string(data, "name", QT_TO_UTF8(ui->scenes->item(i)->text())); - obs_data_array_push_back(sceneOrder, data); + OBSDataAutoRelease orderData = obs_data_create(); + obs_data_set_string(orderData, "name", QT_TO_UTF8(ui->scenes->item(i)->text())); + obs_data_array_push_back(sceneOrder, orderData); } return sceneOrder; @@ -80,8 +80,8 @@ void OBSBasic::LoadSceneListOrder(obs_data_array_t *array) size_t num = obs_data_array_count(array); for (size_t i = 0; i < num; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); - const char *name = obs_data_get_string(data, "name"); + OBSDataAutoRelease itemData = obs_data_array_item(array, i); + const char *name = obs_data_get_string(itemData, "name"); ReorderItemByName(ui->scenes, name, (int)i); } @@ -103,10 +103,10 @@ void OBSBasic::AddScene(OBSSource source) obs_hotkey_register_source( source, "OBSBasic.SelectScene", Str("Basic.Hotkeys.SelectScene"), - [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { OBSBasic *main = OBSBasic::Get(); - auto potential_source = static_cast(data); + auto potential_source = static_cast(handler_data); OBSSourceAutoRelease source = obs_source_get_ref(potential_source); if (source && pressed) { main->SetCurrentScene(source.Get()); @@ -146,8 +146,8 @@ void OBSBasic::AddScene(OBSSource source) SaveProject(); if (!disableSaving) { - obs_source_t *source = obs_scene_get_source(scene); - blog(LOG_INFO, "User added scene '%s'", obs_source_get_name(source)); + obs_source_t *sceneSource = obs_scene_get_source(scene); + blog(LOG_INFO, "User added scene '%s'", obs_source_get_name(sceneSource)); OBSProjector::UpdateMultiviewProjectors(); } @@ -267,33 +267,34 @@ void OBSBasic::DuplicateSelectedScene() continue; } - obs_source_t *source = obs_get_source_by_name(name.c_str()); - if (source) { + obs_source_t *existingSource = obs_get_source_by_name(name.c_str()); + if (existingSource) { OBSMessageBox::warning(this, QTStr("NameExists.Title"), QTStr("NameExists.Text")); - obs_source_release(source); + obs_source_release(existingSource); continue; } OBSSceneAutoRelease scene = obs_scene_duplicate(curScene, name.c_str(), OBS_SCENE_DUP_REFS); - source = obs_scene_get_source(scene); - SetCurrentScene(source, true); + existingSource = obs_scene_get_source(scene); + SetCurrentScene(existingSource, true); - auto undo = [](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_name(data.c_str()); + auto undo = [](const std::string &sceneName) { + OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.c_str()); obs_source_remove(source); }; - auto redo = [this, name](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_name(data.c_str()); + auto redo = [this, name](const std::string &sceneName) { + OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.c_str()); obs_scene_t *scene = obs_scene_from_source(source); scene = obs_scene_duplicate(scene, name.c_str(), OBS_SCENE_DUP_REFS); source = obs_scene_get_source(scene); SetCurrentScene(source.Get(), true); }; - undo_s.add_action(QTStr("Undo.Scene.Duplicate").arg(obs_source_get_name(source)), undo, redo, - obs_source_get_name(source), obs_source_get_name(obs_scene_get_source(curScene))); + undo_s.add_action(QTStr("Undo.Scene.Duplicate").arg(obs_source_get_name(existingSource)), undo, redo, + obs_source_get_name(existingSource), + obs_source_get_name(obs_scene_get_source(curScene))); break; } @@ -460,13 +461,13 @@ void OBSBasic::RemoveSelectedScene() RemoveSceneAndReleaseNested(source); }; - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_array(data, "sources_in_deleted_scene", sources_in_deleted_scene); - obs_data_set_array(data, "scene_used_in_other_scenes", scene_used_in_other_scenes); - obs_data_set_int(data, "index", ui->scenes->currentRow()); + OBSDataAutoRelease undoData = obs_data_create(); + obs_data_set_array(undoData, "sources_in_deleted_scene", sources_in_deleted_scene); + obs_data_set_array(undoData, "scene_used_in_other_scenes", scene_used_in_other_scenes); + obs_data_set_int(undoData, "index", ui->scenes->currentRow()); const char *scene_name = obs_source_get_name(source); - undo_s.add_action(QTStr("Undo.Delete").arg(scene_name), undo, redo, obs_data_get_json(data), scene_name); + undo_s.add_action(QTStr("Undo.Delete").arg(scene_name), undo, redo, obs_data_get_json(undoData), scene_name); /* --------------------------- */ /* remove */ @@ -609,10 +610,10 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) QAction *multiviewAction = popup.addAction(QTStr("ShowInMultiview")); OBSSource source = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(source); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); - obs_data_set_default_bool(data, "show_in_multiview", true); - bool show = obs_data_get_bool(data, "show_in_multiview"); + obs_data_set_default_bool(privateSettings, "show_in_multiview", true); + bool show = obs_data_get_bool(privateSettings, "show_in_multiview"); multiviewAction->setCheckable(true); multiviewAction->setChecked(show); @@ -623,7 +624,8 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) OBSProjector::UpdateMultiviewProjectors(); }; - connect(multiviewAction, &QAction::triggered, multiviewAction, std::bind(showInMultiview, data.Get())); + connect(multiviewAction, &QAction::triggered, multiviewAction, + std::bind(showInMultiview, privateSettings.Get())); copyFilters->setEnabled(obs_source_filter_count(source) > 0); } @@ -687,24 +689,24 @@ void OBSBasic::on_actionAddScene_triggered() return; } - OBSSourceAutoRelease source = obs_get_source_by_name(name.c_str()); - if (source) { + OBSSourceAutoRelease existingSource = obs_get_source_by_name(name.c_str()); + if (existingSource) { OBSMessageBox::warning(this, QTStr("NameExists.Title"), QTStr("NameExists.Text")); on_actionAddScene_triggered(); return; } - auto undo_fn = [](const std::string &data) { - obs_source_t *t = obs_get_source_by_name(data.c_str()); + auto undo_fn = [](const std::string &sceneName) { + obs_source_t *t = obs_get_source_by_name(sceneName.c_str()); if (t) { obs_source_remove(t); obs_source_release(t); } }; - auto redo_fn = [this](const std::string &data) { - OBSSceneAutoRelease scene = obs_scene_create(data.c_str()); + auto redo_fn = [this](const std::string &sceneName) { + OBSSceneAutoRelease scene = obs_scene_create(sceneName.c_str()); obs_source_t *source = obs_scene_get_source(scene); SetCurrentScene(source, true); }; From 074c9d475222743786e4268fd7037ae4c9d6a2b5 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 17:52:02 -0700 Subject: [PATCH 54/63] build(msvc): name the transition, studio-mode and projector locals (#2626) Wave 23: the 23 name-hiding findings left in the wave-22 arm64 app build (run 40793642430, job "Build windows arm64", head 5090b8def), all at the declaration. Every rename is local to one lambda/local scope; no behaviour changes. frontend/widgets/OBSBasic_Transitions.cpp.hpp AddQuickTransitionHotkey / InitTransition lambdas data -> handler_data (4) LoadQuickTransitions data -> itemData SaveQuickTransitions data -> entryData TransitionToProgram: previous program scene lastScene -> previousScene on_transitionProps_clicked: menu lambda properties -> openSourceProperties CreatePerSceneTransitionMenu: private settings data -> privateSettings (3) two undo/redo payload parameters data -> undoJson four programOptions layout locals programLayout -> optionsLayout GetTransitionOverride* private settings data -> privateSettings (2) frontend/widgets/OBSBasic_StudioMode.cpp.hpp SetPreviewProgramMode: scene at exit currentScene -> currentSceneSource UpdatePreviewProgramIndicators: label text program -> programText ProgramViewContextMenuRequested: projector menu studioProgramProjector -> programProjectorMenu frontend/widgets/OBSProjector.cpp.hpp / .hpp AlwaysOnTopToggled / SetIsAlwaysOnTop parameter isAlwaysOnTop -> alwaysOnTop frontend/widgets/OBSBasic_Scenes.cpp.hpp showInMultiview hotkey payload data -> settingsData Refs #2626, Refs #516. --- frontend/widgets/OBSBasic_Scenes.cpp.hpp | 6 +- frontend/widgets/OBSBasic_StudioMode.cpp.hpp | 23 ++-- frontend/widgets/OBSBasic_Transitions.cpp.hpp | 106 +++++++++--------- frontend/widgets/OBSProjector.cpp.hpp | 10 +- frontend/widgets/OBSProjector.hpp | 2 +- 5 files changed, 74 insertions(+), 73 deletions(-) diff --git a/frontend/widgets/OBSBasic_Scenes.cpp.hpp b/frontend/widgets/OBSBasic_Scenes.cpp.hpp index 6520bb3f15..b314004806 100644 --- a/frontend/widgets/OBSBasic_Scenes.cpp.hpp +++ b/frontend/widgets/OBSBasic_Scenes.cpp.hpp @@ -618,9 +618,9 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) multiviewAction->setCheckable(true); multiviewAction->setChecked(show); - auto showInMultiview = [](OBSData data) { - bool show = obs_data_get_bool(data, "show_in_multiview"); - obs_data_set_bool(data, "show_in_multiview", !show); + auto showInMultiview = [](OBSData settingsData) { + bool show = obs_data_get_bool(settingsData, "show_in_multiview"); + obs_data_set_bool(settingsData, "show_in_multiview", !show); OBSProjector::UpdateMultiviewProjectors(); }; diff --git a/frontend/widgets/OBSBasic_StudioMode.cpp.hpp b/frontend/widgets/OBSBasic_StudioMode.cpp.hpp index 658526eee1..5da09d7c38 100644 --- a/frontend/widgets/OBSBasic_StudioMode.cpp.hpp +++ b/frontend/widgets/OBSBasic_StudioMode.cpp.hpp @@ -240,7 +240,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled) "-------------------"); } else { OBSSource actualProgramScene = OBSGetStrongRef(programScene); - OBSSource currentScene = GetCurrentSceneSource(); + OBSSource currentSceneSource = GetCurrentSceneSource(); struct studio_mode_exit_ops ops = {}; ops.param = this; ops.select_scene = [](void *param, void *scene) { @@ -260,7 +260,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled) ops.scene_changed = [](void *param) { static_cast(param)->OnEvent(OBS_FRONTEND_EVENT_SCENE_CHANGED); }; - studio_mode_exit_switch(&ops, actualProgramScene.Get(), currentScene.Get()); + studio_mode_exit_switch(&ops, actualProgramScene.Get(), currentSceneSource.Get()); delete programOptions; delete program; @@ -365,14 +365,15 @@ void OBSBasic::UpdatePreviewProgramIndicators() QString preview = QTStr("StudioMode.PreviewSceneName").arg(QT_UTF8(obs_source_get_name(GetCurrentSceneSource()))); - QString program = QTStr("StudioMode.ProgramSceneName").arg(QT_UTF8(obs_source_get_name(GetProgramSource()))); + QString programText = + QTStr("StudioMode.ProgramSceneName").arg(QT_UTF8(obs_source_get_name(GetProgramSource()))); if (ui->previewLabel->text() != preview) { ui->previewLabel->setText(preview); } - if (programLabel && programLabel->text() != program) { - programLabel->setText(program); + if (programLabel && programLabel->text() != programText) { + programLabel->setText(programText); } } @@ -384,14 +385,14 @@ OBSSource OBSBasic::GetProgramSource() void OBSBasic::ProgramViewContextMenuRequested() { QMenu popup(this); - QPointer studioProgramProjector; + QPointer programProjectorMenu; - studioProgramProjector = new QMenu(QTStr("Projector.Open.Program")); - AddProjectorMenuMonitors(studioProgramProjector, this, &OBSBasic::OpenStudioProgramProjector); - studioProgramProjector->addSeparator(); - studioProgramProjector->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenStudioProgramWindow); + programProjectorMenu = new QMenu(QTStr("Projector.Open.Program")); + AddProjectorMenuMonitors(programProjectorMenu, this, &OBSBasic::OpenStudioProgramProjector); + programProjectorMenu->addSeparator(); + programProjectorMenu->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenStudioProgramWindow); - popup.addMenu(studioProgramProjector); + popup.addMenu(programProjectorMenu); popup.addSeparator(); popup.addAction(QTStr("Screenshot.StudioProgram"), this, &OBSBasic::ScreenshotProgram); diff --git a/frontend/widgets/OBSBasic_Transitions.cpp.hpp b/frontend/widgets/OBSBasic_Transitions.cpp.hpp index 54443a3847..f11a7a7208 100644 --- a/frontend/widgets/OBSBasic_Transitions.cpp.hpp +++ b/frontend/widgets/OBSBasic_Transitions.cpp.hpp @@ -89,8 +89,8 @@ void OBSBasic::AddQuickTransitionHotkey(QuickTransition *qt) dstr_printf(hotkeyId, "OBSBasic.QuickTransition.%d", qt->id); hotkeyName = QTStr("QuickTransitions.HotkeyName").arg(TransitionsQuickTransitionText(qt)); - auto quickTransition = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - int id = (int)(uintptr_t)data; + auto quickTransition = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + int id = (int)(uintptr_t)handler_data; OBSBasic *main = OBSBasic::Get(); if (pressed) { @@ -126,18 +126,18 @@ void OBSBasic::RemoveQuickTransitionHotkey(QuickTransition *qt) void OBSBasic::InitTransition(obs_source_t *transition) { - auto onTransitionStart = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionStart = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionStarted, Qt::QueuedConnection); }; - auto onTransitionStop = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionStop = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionStopped, Qt::QueuedConnection); }; - auto onTransitionFullStop = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionFullStop = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionFullyStopped, Qt::QueuedConnection); }; @@ -168,12 +168,12 @@ void OBSBasic::LoadQuickTransitions(obs_data_array_t *array) quickTransitionIdCounter = 1; for (size_t i = 0; i < count; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); - OBSDataArrayAutoRelease hotkeys = obs_data_get_array(data, "hotkeys"); - const char *name = obs_data_get_string(data, "name"); - int duration = obs_data_get_int(data, "duration"); - int id = obs_data_get_int(data, "id"); - bool toBlack = obs_data_get_bool(data, "fade_to_black"); + OBSDataAutoRelease itemData = obs_data_array_item(array, i); + OBSDataArrayAutoRelease hotkeys = obs_data_get_array(itemData, "hotkeys"); + const char *name = obs_data_get_string(itemData, "name"); + int duration = obs_data_get_int(itemData, "duration"); + int id = obs_data_get_int(itemData, "id"); + bool toBlack = obs_data_get_bool(itemData, "fade_to_black"); if (id) { obs_source_t *source = FindTransition(name); @@ -198,17 +198,17 @@ obs_data_array_t *OBSBasic::SaveQuickTransitions() obs_data_array_t *array = obs_data_array_create(); for (QuickTransition &qt : quickTransitions) { - OBSDataAutoRelease data = obs_data_create(); + OBSDataAutoRelease entryData = obs_data_create(); OBSDataArrayAutoRelease hotkeys = obs_hotkey_save(qt.hotkey); MarkSavedHotkeys(hotkeys); - obs_data_set_string(data, "name", obs_source_get_name(qt.source)); - obs_data_set_int(data, "duration", qt.duration); - obs_data_set_array(data, "hotkeys", hotkeys); - obs_data_set_int(data, "id", qt.id); - obs_data_set_bool(data, "fade_to_black", qt.fadeToBlack); + obs_data_set_string(entryData, "name", obs_source_get_name(qt.source)); + obs_data_set_int(entryData, "duration", qt.duration); + obs_data_set_array(entryData, "hotkeys", hotkeys); + obs_data_set_int(entryData, "id", qt.id); + obs_data_set_bool(entryData, "fade_to_black", qt.fadeToBlack); - obs_data_array_push_back(array, data); + obs_data_array_push_back(array, entryData); } return array; @@ -323,13 +323,13 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force, bool quickTransit programScene = OBSGetWeakRef(source); if (!force && !black) { - OBSSource lastScene = OBSGetStrongRef(lastProgramScene); + OBSSource previousScene = OBSGetStrongRef(lastProgramScene); - if (!sceneDuplicationMode && lastScene == source) { + if (!sceneDuplicationMode && previousScene == source) { return; } - if (swapScenesMode && lastScene && lastScene != GetCurrentSceneSource()) { + if (swapScenesMode && previousScene && previousScene != GetCurrentSceneSource()) { swapScene = lastProgramScene; swapPreviewScene = OBSGetWeakRef(GetCurrentSceneSource()); } @@ -656,7 +656,7 @@ void OBSBasic::on_transitionProps_clicked() return; } - auto properties = [&]() { + auto openSourceProperties = [&]() { CreatePropertiesWindow(source); }; @@ -667,7 +667,7 @@ void OBSBasic::on_transitionProps_clicked() menu.addAction(action); action = new QAction(QTStr("Properties"), &menu); - connect(action, &QAction::triggered, this, properties); + connect(action, &QAction::triggered, this, openSourceProperties); menu.addAction(action); menu.exec(QCursor::pos()); @@ -895,12 +895,12 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() OBSSource scene = GetCurrentSceneSource(); QMenu *menu = new QMenu(QTStr("TransitionOverride")); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); - obs_data_set_default_int(data, "transition_duration", 300); + obs_data_set_default_int(privateSettings, "transition_duration", 300); - const char *curTransition = obs_data_get_string(data, "transition"); - int curDuration = (int)obs_data_get_int(data, "transition_duration"); + const char *curTransition = obs_data_get_string(privateSettings, "transition"); + int curDuration = (int)obs_data_get_int(privateSettings, "transition_duration"); QSpinBox *duration = new QSpinBox(menu); duration->setMinimum(50); @@ -912,12 +912,12 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() auto setTransition = [this](QAction *action) { std::string uuid = action->property("transition_uuid").toString().toStdString(); OBSSource scene = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); auto transitionIter = transitions.find(uuid); OBSSource transition; if (uuid.empty()) { - obs_data_set_string(data, "transition", ""); + obs_data_set_string(privateSettings, "transition", ""); return; } @@ -929,15 +929,15 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() if (transition) { const char *name = obs_source_get_name(transition); - obs_data_set_string(data, "transition", name); + obs_data_set_string(privateSettings, "transition", name); } }; auto setDuration = [this](int duration) { OBSSource scene = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); - obs_data_set_int(data, "transition_duration", duration); + obs_data_set_int(privateSettings, "transition_duration", duration); }; connect(duration, &QSpinBox::valueChanged, this, setDuration); @@ -1007,12 +1007,12 @@ void OBSBasic::PasteShowHideTransition(obs_sceneitem_t *item, bool show, obs_sou int64_t sceneItemId = obs_sceneitem_get_id(item); std::string sceneUUID = obs_source_get_uuid(obs_scene_get_source(obs_sceneitem_get_scene(item))); - auto undo_redo = [sceneUUID, sceneItemId, show](const std::string &data) { + auto undo_redo = [sceneUUID, sceneItemId, show](const std::string &undoJson) { OBSSourceAutoRelease source = obs_get_source_by_uuid(sceneUUID.c_str()); obs_scene_t *scene = obs_scene_from_source(source); obs_sceneitem_t *i = obs_scene_find_sceneitem_by_id(scene, sceneItemId); if (i) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(undoJson.c_str()); obs_sceneitem_transition_load(i, dat, show); } }; @@ -1089,8 +1089,8 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) .arg(QString::number(count)); } - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &undoJson) { + OBSDataAutoRelease dat = obs_data_create_from_json(undoJson.c_str()); visibility_transition_restore(dat); }; main->undo_s.add_action(text, undo_redo, undo_redo, obs_data_get_json(undo_data), @@ -1262,11 +1262,11 @@ void OBSBasic::AddQuickTransitionId(int id) button->setMenu(buttonMenu); connect(button, &QAbstractButton::clicked, this, &OBSBasic::QuickTransitionClicked); - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); int idx = 3; for (;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1277,7 +1277,7 @@ void OBSBasic::AddQuickTransitionId(int id) } } - programLayout->insertWidget(idx, button); + optionsLayout->insertWidget(idx, button); } void OBSBasic::AddQuickTransition() @@ -1318,10 +1318,10 @@ void OBSBasic::ClearQuickTransitions() return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1405,10 +1405,10 @@ void OBSBasic::ClearQuickTransitionWidgets() return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1452,10 +1452,10 @@ void OBSBasic::EnableTransitionWidgets(bool enable) return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1538,9 +1538,9 @@ OBSSource OBSBasic::GetOverrideTransition(OBSSource source) return nullptr; } - OBSDataAutoRelease data = obs_source_get_private_settings(source); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); - const char *trOverrideName = obs_data_get_string(data, "transition"); + const char *trOverrideName = obs_data_get_string(privateSettings, "transition"); OBSSource trOverride = nullptr; @@ -1557,10 +1557,10 @@ int OBSBasic::GetOverrideTransitionDuration(OBSSource source) return 300; } - OBSDataAutoRelease data = obs_source_get_private_settings(source); - obs_data_set_default_int(data, "transition_duration", 300); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); + obs_data_set_default_int(privateSettings, "transition_duration", 300); - return (int)obs_data_get_int(data, "transition_duration"); + return (int)obs_data_get_int(privateSettings, "transition_duration"); } int OBSBasic::GetTransitionDuration() diff --git a/frontend/widgets/OBSProjector.cpp.hpp b/frontend/widgets/OBSProjector.cpp.hpp index def412f727..a9e9358434 100644 --- a/frontend/widgets/OBSProjector.cpp.hpp +++ b/frontend/widgets/OBSProjector.cpp.hpp @@ -440,9 +440,9 @@ void OBSProjector::ResizeToContent() resize(newX, newY); } -void OBSProjector::AlwaysOnTopToggled(bool isAlwaysOnTop) +void OBSProjector::AlwaysOnTopToggled(bool alwaysOnTop) { - SetIsAlwaysOnTop(isAlwaysOnTop, true); + SetIsAlwaysOnTop(alwaysOnTop, true); } void OBSProjector::closeEvent(QCloseEvent *event) @@ -461,12 +461,12 @@ bool OBSProjector::IsAlwaysOnTopOverridden() const return isAlwaysOnTopOverridden; } -void OBSProjector::SetIsAlwaysOnTop(bool isAlwaysOnTop, bool isOverridden) +void OBSProjector::SetIsAlwaysOnTop(bool alwaysOnTop, bool isOverridden) { - this->isAlwaysOnTop = isAlwaysOnTop; + this->isAlwaysOnTop = alwaysOnTop; this->isAlwaysOnTopOverridden = isOverridden; - SetAlwaysOnTop(this, isAlwaysOnTop); + SetAlwaysOnTop(this, alwaysOnTop); } void OBSProjector::ScreenRemoved(QScreen *screen) diff --git a/frontend/widgets/OBSProjector.hpp b/frontend/widgets/OBSProjector.hpp index 7f9cd4a4a1..c3b9c48b46 100644 --- a/frontend/widgets/OBSProjector.hpp +++ b/frontend/widgets/OBSProjector.hpp @@ -64,5 +64,5 @@ private slots: bool IsAlwaysOnTop() const; bool IsAlwaysOnTopOverridden() const; - void SetIsAlwaysOnTop(bool isAlwaysOnTop, bool isOverridden); + void SetIsAlwaysOnTop(bool alwaysOnTop, bool isOverridden); }; From 852bcb1f5f76f5315d77fdd0d11b825065fe2f5f Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 17:52:02 -0700 Subject: [PATCH 55/63] build(msvc): lead HandleFindData with its over-aligned member (#2626) The arm64 Windows app lane reports C4324 on the struct: `matrix4` carries a 16-byte-aligned SIMD member (a vec4), and it sat after `const vec2 &pos` and `const float radius`, so the compiler inserted padding. x64 does not report it, which is why the wave loop had not seen it before (arm64 job 123184945877, head 5090b8def). Move `parent_xform` first and group the remaining members so each lands at its natural offset: 64 + 8 + 8 + 8 + 8 + 4 + 4 + 4 + 4 = 112 bytes, an exact multiple of the 16-byte alignment, so no padding is inserted anywhere. The second constructor's init list follows the new declaration order. No behaviour change; the struct is internal to the preview widget and only ever passed by pointer to obs_scene_enum_items. Refs #2626, Refs #516. --- frontend/widgets/OBSBasicPreview.cpp.hpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/widgets/OBSBasicPreview.cpp.hpp b/frontend/widgets/OBSBasicPreview.cpp.hpp index badb86abf5..24b0b5ea3c 100644 --- a/frontend/widgets/OBSBasicPreview.cpp.hpp +++ b/frontend/widgets/OBSBasicPreview.cpp.hpp @@ -348,16 +348,20 @@ bool OBSBasicPreview::SelectedAtPos(const vec2 &pos) } struct HandleFindData { - const vec2 &pos; - const float radius; + /* parent_xform is 16-byte aligned (vec4 carries the SIMD type), so it + * leads the struct: every other member then lands at its natural offset + * and the size stays a multiple of the alignment, with no padding to + * warn about (C4324). */ matrix4 parent_xform; + const vec2 &pos; OBSSceneItem item; - ItemHandle handle = ItemHandle::None; - float angle = 0.0f; vec2 rotatePoint; vec2 offsetPoint; + const float radius; + ItemHandle handle = ItemHandle::None; + float angle = 0.0f; float angleOffset = 0.0f; HandleFindData(const HandleFindData &) = delete; @@ -372,12 +376,12 @@ struct HandleFindData { inline HandleFindData(const HandleFindData &hfd, obs_sceneitem_t *parent) : pos(hfd.pos), - radius(hfd.radius), item(hfd.item), - handle(hfd.handle), - angle(hfd.angle), rotatePoint(hfd.rotatePoint), - offsetPoint(hfd.offsetPoint) + offsetPoint(hfd.offsetPoint), + radius(hfd.radius), + handle(hfd.handle), + angle(hfd.angle) { obs_sceneitem_get_draw_transform(parent, &parent_xform); } From d3feb203bd6a4c6c37757539489462c7228614d4 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 18:07:44 -0700 Subject: [PATCH 56/63] build(msvc): initialize the popup menu's source and flags (#2626) Wave 24, read from the x64 log of the 8ed8fdeaa app build (job 123195796173): /W4 flags C4701/C4703 at CreateSourcePopupMenu, where obs_source_t *source and uint32_t flags are declared before the sourceSelected branch and used after it. Both now start at nullptr/0, so the no-selection path can no longer read an indeterminate local (behaviour is unchanged: every use is already behind sourceSelected or hasVideo/hasAudio). --- frontend/widgets/OBSBasic_SceneItems.cpp.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/widgets/OBSBasic_SceneItems.cpp.hpp b/frontend/widgets/OBSBasic_SceneItems.cpp.hpp index 16d2203b6f..fe460cccf8 100644 --- a/frontend/widgets/OBSBasic_SceneItems.cpp.hpp +++ b/frontend/widgets/OBSBasic_SceneItems.cpp.hpp @@ -561,8 +561,8 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) delete deinterlaceMenu; OBSSceneItem sceneItem; - obs_source_t *source; - uint32_t flags; + obs_source_t *source = nullptr; + uint32_t flags = 0; bool isAsyncVideo = false; bool hasAudio = false; bool hasVideo = false; From f9d5a62c611a2e1964c7ad0d0c96a0458b048a28 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 18:39:58 -0700 Subject: [PATCH 57/63] fix(shared): spell the address length conversion in the socket platform layer (#2626) The Windows Tier 2 lane now compiles shared/ at /W4, and it is the first lane to reach happy-eyeballs there: the x64 PR run failed with happy-eyeballs.c.h(317,65): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data => error C2220: the following warning is treated as an error connect()/bind() take the address length as an int in Winsock and as a socklen_t in BSD sockets, while the resolved length is a size_t. The call sites had a bare (int) cast on connect() and none on bind(), so the narrowing was invisible to the portability layer. Both now go through a host-layer helper, he_platform_addr_len(), which returns the type the platform's call expects: an int on Windows, a socklen_t elsewhere. No value changes - the same narrowing happens, spelled where the platform knows its own signature. --- shared/happy-eyeballs/happy-eyeballs.c.h | 6 +++--- .../happy-eyeballs/hosts/posix/happy-eyeballs-platform.h | 7 +++++++ .../hosts/windows/happy-eyeballs-platform.h | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/shared/happy-eyeballs/happy-eyeballs.c.h b/shared/happy-eyeballs/happy-eyeballs.c.h index f871d38cdf..fcfb7969a9 100644 --- a/shared/happy-eyeballs/happy-eyeballs.c.h +++ b/shared/happy-eyeballs/happy-eyeballs.c.h @@ -309,12 +309,12 @@ static void *happy_connect_worker(void *arg) } he_platform_socket_nosigpipe(args->sockfd); - if (context->bind_addr.ss_family != 0 && - bind(args->sockfd, (const struct sockaddr *)&context->bind_addr, context->bind_addr_len) < 0) { + if (context->bind_addr.ss_family != 0 && bind(args->sockfd, (const struct sockaddr *)&context->bind_addr, + he_platform_addr_len(context->bind_addr_len)) < 0) { goto failure; } - if (connect(args->sockfd, args->address->ai_addr, args->address->ai_addrlen) == 0) { + if (connect(args->sockfd, args->address->ai_addr, he_platform_addr_len(args->address->ai_addrlen)) == 0) { /* success, check if we're the winner. */ pthread_mutex_lock(&context->winner_mutex); diff --git a/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h b/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h index 254e5c798a..276496272d 100644 --- a/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h +++ b/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h @@ -62,3 +62,10 @@ static inline void he_platform_socket_nosigpipe(SOCKET fd) (void)fd; #endif } + +/* BSD sockets take the address length as a socklen_t; the resolved length is + * a size_t, so narrow it the way the call already did implicitly. */ +static inline socklen_t he_platform_addr_len(size_t len) +{ + return (socklen_t)len; +} diff --git a/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h b/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h index a8171a75c8..c4501139d4 100644 --- a/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h +++ b/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h @@ -62,3 +62,11 @@ static inline void he_platform_socket_nosigpipe(SOCKET fd) { (void)fd; } + +/* Winsock's bind()/connect() take the address length as an int, while the + * resolved length is a size_t; the conversion is the one the call already + * made implicitly, so it is spelled out here rather than at the call sites. */ +static inline int he_platform_addr_len(size_t len) +{ + return (int)len; +} From 6f62d603688a724b81d2f3982212db518f75f972 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 18:41:43 -0700 Subject: [PATCH 58/63] build(msvc): name the wizard and app locals after what they hold (#2626) Wave 24, part 2: the frontend findings the arm64 /W4 log of the 40798517408 verify run reported after the popup-menu pair. - AutoConfig.cpp.hpp: the hardware-preference local becomes preferHardwareEncoding (the member it hid is preferHardware), and CanTestServer's parameter becomes serverAddress (it hid the member server). - AutoConfigStreamPage.cpp.hpp: the multitrack service settings blob becomes multitrack_service_settings, and the per-endpoint bitrate becomes endpoint_bitrate (both hid an earlier local in SaveStreamSettings). - AutoConfigTestPage.cpp.hpp: the two signal-handler lambdas take handler_data, and the two local result vectors become testResults (they hid the QFormLayout member results). - OBSApp.cpp.hpp: InitUserConfig's parameter becomes configLocation (it hid the userConfigLocation member) and obs-main.cpp.hpp's inner nextLine becomes lineEnd. Source-only renames; no test or flag change. ci/test_msvc_warning_level.py 15 tests OK and ./lint ok. --- frontend/OBSApp.cpp.hpp | 4 +- frontend/OBSApp.hpp | 2 +- frontend/obs-main.cpp.hpp | 14 +++--- frontend/wizards/AutoConfig.cpp.hpp | 14 +++--- frontend/wizards/AutoConfig.hpp | 2 +- frontend/wizards/AutoConfigStreamPage.cpp.hpp | 13 +++--- frontend/wizards/AutoConfigTestPage.cpp.hpp | 44 +++++++++---------- 7 files changed, 47 insertions(+), 46 deletions(-) diff --git a/frontend/OBSApp.cpp.hpp b/frontend/OBSApp.cpp.hpp index af20339235..049ab28727 100644 --- a/frontend/OBSApp.cpp.hpp +++ b/frontend/OBSApp.cpp.hpp @@ -631,9 +631,9 @@ bool OBSApp::InitGlobalConfig() return userConfigResult; } -bool OBSApp::InitUserConfig(std::filesystem::path &userConfigLocation, uint32_t lastVersion) +bool OBSApp::InitUserConfig(std::filesystem::path &configLocation, uint32_t lastVersion) { - const std::string userConfigFile = userConfigLocation.u8string() + "/" OBS_CONFIG_DIRECTORY "/user.ini"; + const std::string userConfigFile = configLocation.u8string() + "/" OBS_CONFIG_DIRECTORY "/user.ini"; int errorCode = userConfig.Open(userConfigFile.c_str(), CONFIG_OPEN_ALWAYS); diff --git a/frontend/OBSApp.hpp b/frontend/OBSApp.hpp index 097883e83a..3b30fa541e 100644 --- a/frontend/OBSApp.hpp +++ b/frontend/OBSApp.hpp @@ -110,7 +110,7 @@ class OBSApp : public QApplication { void InitCrashHandler(); void MigrateLegacySettings(uint32_t lastVersion); - bool InitUserConfig(std::filesystem::path &userConfigLocation, uint32_t lastVersion); + bool InitUserConfig(std::filesystem::path &configLocation, uint32_t lastVersion); void InitUserConfigDefaults(); bool InitLocale(); diff --git a/frontend/obs-main.cpp.hpp b/frontend/obs-main.cpp.hpp index 9effc9dbf2..8cfd78c244 100644 --- a/frontend/obs-main.cpp.hpp +++ b/frontend/obs-main.cpp.hpp @@ -144,20 +144,20 @@ static inline void LogStringChunk(fstream &logFile, char *str, int log_level) timeString += ": "; while (*nextLine) { - char *nextLine = strchr(str, '\n'); - if (!nextLine) { + char *lineEnd = strchr(str, '\n'); + if (!lineEnd) { break; } - if (nextLine != str && nextLine[-1] == '\r') { - nextLine[-1] = 0; + if (lineEnd != str && lineEnd[-1] == '\r') { + lineEnd[-1] = 0; } else { - nextLine[0] = 0; + lineEnd[0] = 0; } LogString(logFile, timeString.c_str(), str, log_level); - nextLine++; - str = nextLine; + lineEnd++; + str = lineEnd; } LogString(logFile, timeString.c_str(), str, log_level); diff --git a/frontend/wizards/AutoConfig.cpp.hpp b/frontend/wizards/AutoConfig.cpp.hpp index 6d15e7be1f..e57c6809b0 100644 --- a/frontend/wizards/AutoConfig.cpp.hpp +++ b/frontend/wizards/AutoConfig.cpp.hpp @@ -169,8 +169,8 @@ AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent) /* Newer generations of NVENC have a high enough quality to * bitrate ratio that if NVENC is available, it makes sense to * just always prefer hardware encoding by default */ - bool preferHardware = nvencAvailable || appleAvailable || os_get_physical_cores() <= 4; - streamPage->ui->preferHardware->setChecked(preferHardware); + bool preferHardwareEncoding = nvencAvailable || appleAvailable || os_get_physical_cores() <= 4; + streamPage->ui->preferHardware->setChecked(preferHardwareEncoding); } setOptions(QWizard::WizardOptions()); @@ -204,19 +204,19 @@ void AutoConfig::TestHardwareEncoding() } } -bool AutoConfig::CanTestServer(const char *server) +bool AutoConfig::CanTestServer(const char *serverAddress) { if (!testRegions || (regionUS && regionEU && regionAsia && regionOther)) { return true; } if (service == Service::Twitch) { - if (astrcmp_n(server, "US West:", 8) == 0 || astrcmp_n(server, "US East:", 8) == 0 || - astrcmp_n(server, "US Central:", 11) == 0) { + if (astrcmp_n(serverAddress, "US West:", 8) == 0 || astrcmp_n(serverAddress, "US East:", 8) == 0 || + astrcmp_n(serverAddress, "US Central:", 11) == 0) { return regionUS; - } else if (astrcmp_n(server, "EU:", 3) == 0) { + } else if (astrcmp_n(serverAddress, "EU:", 3) == 0) { return regionEU; - } else if (astrcmp_n(server, "Asia:", 5) == 0) { + } else if (astrcmp_n(serverAddress, "Asia:", 5) == 0) { return regionAsia; } else if (regionOther) { return true; diff --git a/frontend/wizards/AutoConfig.hpp b/frontend/wizards/AutoConfig.hpp index 92fa568f98..53e0f8c188 100644 --- a/frontend/wizards/AutoConfig.hpp +++ b/frontend/wizards/AutoConfig.hpp @@ -104,7 +104,7 @@ class AutoConfig : public QWizard { int specificFPSDen = 0; void TestHardwareEncoding(); - bool CanTestServer(const char *server); + bool CanTestServer(const char *serverAddress); virtual void done(int result) override; diff --git a/frontend/wizards/AutoConfigStreamPage.cpp.hpp b/frontend/wizards/AutoConfigStreamPage.cpp.hpp index 09f3eebdf1..7c8c84ba69 100644 --- a/frontend/wizards/AutoConfigStreamPage.cpp.hpp +++ b/frontend/wizards/AutoConfigStreamPage.cpp.hpp @@ -165,10 +165,11 @@ bool AutoConfigStreamPage::validatePage() auto postData = constructGoLivePost(QString::fromStdString(wiz->key), std::nullopt, std::nullopt, false, canvases); - OBSDataAutoRelease service_settings = obs_service_get_settings(service); + OBSDataAutoRelease multitrack_service_settings = obs_service_get_settings(service); auto multitrack_video_name = QTStr("Basic.Settings.Stream.MultitrackVideoLabel"); - if (obs_data_has_user_value(service_settings, "multitrack_video_name")) { - multitrack_video_name = obs_data_get_string(service_settings, "multitrack_video_name"); + if (obs_data_has_user_value(multitrack_service_settings, "multitrack_video_name")) { + multitrack_video_name = + obs_data_get_string(multitrack_service_settings, "multitrack_video_name"); } try { @@ -200,9 +201,9 @@ bool AutoConfigStreamPage::validatePage() continue; } - int bitrate = 0; - it->get_to(bitrate); - multitrackVideoBitrate += bitrate; + int endpoint_bitrate = 0; + it->get_to(endpoint_bitrate); + multitrackVideoBitrate += endpoint_bitrate; } if (multitrackVideoBitrate > 0) { diff --git a/frontend/wizards/AutoConfigTestPage.cpp.hpp b/frontend/wizards/AutoConfigTestPage.cpp.hpp index 85f067d450..05e923db95 100644 --- a/frontend/wizards/AutoConfigTestPage.cpp.hpp +++ b/frontend/wizards/AutoConfigTestPage.cpp.hpp @@ -284,13 +284,13 @@ void AutoConfigTestPage::TestBandwidthThread() using on_started_t = decltype(on_started); using on_stopped_t = decltype(on_stopped); - auto pre_on_started = [](void *data, calldata_t *) { - on_started_t &on_started = *static_cast(data); + auto pre_on_started = [](void *handler_data, calldata_t *) { + on_started_t &on_started = *static_cast(handler_data); on_started(); }; - auto pre_on_stopped = [](void *data, calldata_t *) { - on_stopped_t &on_stopped = *static_cast(data); + auto pre_on_stopped = [](void *handler_data, calldata_t *) { + on_stopped_t &on_stopped = *static_cast(handler_data); on_stopped(); }; @@ -524,8 +524,8 @@ bool AutoConfigTestPage::TestSoftwareEncoding() using on_stopped_t = decltype(on_stopped); - auto pre_on_stopped = [](void *data, calldata_t *) { - on_stopped_t &on_stopped = *static_cast(data); + auto pre_on_stopped = [](void *handler_data, calldata_t *) { + on_stopped_t &on_stopped = *static_cast(handler_data); on_stopped(); }; @@ -565,7 +565,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() /* -----------------------------------*/ /* perform tests */ - vector results; + vector testResults; int i = 0; int count = 1; @@ -578,7 +578,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() } /* no need for more than 3 tests max */ - if (results.size() >= 3) { + if (testResults.size() >= 3) { return true; } @@ -636,7 +636,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() int skipped = (int)video_output_get_skipped_frames(obs_get_video()); if (force || skipped <= 10) { - results.emplace_back(cx, cy, fps_num, fps_den); + testResults.emplace_back(cx, cy, fps_num, fps_den); } return !cancel; @@ -716,19 +716,19 @@ bool AutoConfigTestPage::TestSoftwareEncoding() int minArea = 960 * 540 + 1000; - if (!wiz->specificFPSNum && wiz->preferHighFPS && results.size() > 1) { - Result &result1 = results[0]; - Result &result2 = results[1]; + if (!wiz->specificFPSNum && wiz->preferHighFPS && testResults.size() > 1) { + Result &result1 = testResults[0]; + Result &result2 = testResults[1]; if (result1.fps_num == 30 && result2.fps_num == 60) { int nextArea = result2.cx * result2.cy; if (nextArea >= minArea) { - results.erase(results.begin()); + testResults.erase(testResults.begin()); } } } - Result result = results.front(); + Result result = testResults.front(); wiz->idealResolutionCX = result.cx; wiz->idealResolutionCY = result.cy; wiz->idealFPSNum = result.fps_num; @@ -762,7 +762,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() int baseCY = wiz->baseResolutionCY; CalcBaseRes(baseCX, baseCY); - vector results; + vector testResults; int pcores = os_get_physical_cores(); int maxDataRate; @@ -777,7 +777,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() return; } - if (results.size() >= 3) { + if (testResults.size() >= 3) { return; } @@ -812,7 +812,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() force = true; } if (force || wiz->idealBitrate >= minBitrate) { - results.emplace_back(cx, cy, fps_num, fps_den); + testResults.emplace_back(cx, cy, fps_num, fps_den); } }; @@ -843,19 +843,19 @@ void AutoConfigTestPage::FindIdealHardwareResolution() int minArea = 960 * 540 + 1000; - if (!wiz->specificFPSNum && wiz->preferHighFPS && results.size() > 1) { - Result &result1 = results[0]; - Result &result2 = results[1]; + if (!wiz->specificFPSNum && wiz->preferHighFPS && testResults.size() > 1) { + Result &result1 = testResults[0]; + Result &result2 = testResults[1]; if (result1.fps_num == 30 && result2.fps_num == 60) { int nextArea = result2.cx * result2.cy; if (nextArea >= minArea) { - results.erase(results.begin()); + testResults.erase(testResults.begin()); } } } - Result result = results.front(); + Result result = testResults.front(); wiz->idealResolutionCX = result.cx; wiz->idealResolutionCY = result.cy; wiz->idealFPSNum = result.fps_num; From dea368ff08f7008d962827b9359fee589bf150db Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 19:04:26 -0700 Subject: [PATCH 59/63] build(msvc): make ParseMath's variable type chain exhaustive (#2626) Wave 25: the /W4 finding in the next frontend unity TU after the wave-24 renames. ParseMath() enters its calc/max/min branch only when one of the three tokens matched, but the third test was a redundant cf_token_is() that MSVC could not use to prove the variable was assigned (C4701 'varType' potentially uninitialized, used at 250). The trailing test becomes the else arm and says why it is exhaustive; no behaviour change. --- frontend/OBSApp_Themes.cpp.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/OBSApp_Themes.cpp.hpp b/frontend/OBSApp_Themes.cpp.hpp index 8984a8285e..a6a4f221b9 100644 --- a/frontend/OBSApp_Themes.cpp.hpp +++ b/frontend/OBSApp_Themes.cpp.hpp @@ -239,7 +239,8 @@ static bool ParseMath(CFParser &cfp, QStringList &values, vector Date: Wed, 28 Oct 2026 19:27:15 -0700 Subject: [PATCH 60/63] build(msvc): drop the unused path and cast the detour hook (#2626) Wave 26: the two /W4 findings in frontend/utility after the wave-25 fix. - platform-windows.cpp.hpp: SaveJxrImage() never used its path argument (the caller's stream is already initialized from the filename), so the parameter and its one call-site argument are gone (C4100). - win-dll-blocklist.c.h: DetourAttach() takes the hook as a data pointer; the implicit function-to-data conversion is a nonstandard extension (C4152). Spell the conversion as an explicit (PVOID) cast, which is what Detours' own C examples do, rather than suppressing the class the way shared/obs-scripting does for SWIG. No behaviour change; ./lint ok and ci/test_msvc_warning_level.py OK. --- frontend/utility/platform-windows.cpp.hpp | 4 ++-- frontend/utility/win-dll-blocklist.c.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/utility/platform-windows.cpp.hpp b/frontend/utility/platform-windows.cpp.hpp index d29b5f6262..67c76471cc 100644 --- a/frontend/utility/platform-windows.cpp.hpp +++ b/frontend/utility/platform-windows.cpp.hpp @@ -963,7 +963,7 @@ bool UseNativeComboBoxPopup() return false; } -static HRESULT SaveJxrImage(LPCWSTR path, uint8_t *pixels, uint32_t cx, uint32_t cy, IWICBitmapFrameEncode *frameEncode, +static HRESULT SaveJxrImage(uint8_t *pixels, uint32_t cx, uint32_t cy, IWICBitmapFrameEncode *frameEncode, IPropertyBag2 *options) { wchar_t lossless[] = L"Lossless"; @@ -1053,7 +1053,7 @@ static HRESULT SaveJxr(LPCWSTR path, uint8_t *pixels, uint32_t cx, uint32_t cy) return hr; } - hr = SaveJxrImage(path, pixels, cx, cy, frameEncode.Get(), options.Get()); + hr = SaveJxrImage(pixels, cx, cy, frameEncode.Get(), options.Get()); if (FAILED(hr)) { return hr; } diff --git a/frontend/utility/win-dll-blocklist.c.h b/frontend/utility/win-dll-blocklist.c.h index d61846b259..a92154d402 100644 --- a/frontend/utility/win-dll-blocklist.c.h +++ b/frontend/utility/win-dll-blocklist.c.h @@ -363,7 +363,9 @@ void install_dll_blocklist_hook(void) DetourTransactionBegin(); - if (DetourAttach((PVOID *)&ntMap, NtMapViewOfSection_hook) != NO_ERROR) { + /* Detours stores hooks as data pointers: the cast is the documented + * way to hand it a function address (MSVC C4152 on the implicit form). */ + if (DetourAttach((PVOID *)&ntMap, (PVOID)NtMapViewOfSection_hook) != NO_ERROR) { DetourTransactionAbort(); } else { DetourTransactionCommit(); From 99cca6c024041959935a70b568ab4d166f02be8c Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 19:28:50 -0700 Subject: [PATCH 61/63] build(msvc): copy the detour hook address through a union, not a cast An explicit function-to-data pointer cast is still C4152 at /W4; MSVC warns on the conversion, not on its implicitness. Copy the address through a union the way GET_DBGHELP_IMPORT does for GetProcAddress, which the repo already relies on to keep this class quiet without a per-file /wd. Refs #2626 --- frontend/utility/win-dll-blocklist.c.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/utility/win-dll-blocklist.c.h b/frontend/utility/win-dll-blocklist.c.h index a92154d402..559a036f4f 100644 --- a/frontend/utility/win-dll-blocklist.c.h +++ b/frontend/utility/win-dll-blocklist.c.h @@ -363,9 +363,17 @@ void install_dll_blocklist_hook(void) DetourTransactionBegin(); - /* Detours stores hooks as data pointers: the cast is the documented - * way to hand it a function address (MSVC C4152 on the implicit form). */ - if (DetourAttach((PVOID *)&ntMap, (PVOID)NtMapViewOfSection_hook) != NO_ERROR) { + /* Detours stores hooks as data pointers, and a cast from a function + * pointer to a data pointer is C4152 at /W4 even when it is explicit. + * Copy the address through a union instead, the way GET_DBGHELP_IMPORT + * (libobs/obs-win-crash-handler.c.h) does for GetProcAddress. No code is + * generated for the copy. */ + union { + fn_NtMapViewOfSection fn; + PVOID obj; + } detour = {NtMapViewOfSection_hook}; + + if (DetourAttach((PVOID *)&ntMap, detour.obj) != NO_ERROR) { DetourTransactionAbort(); } else { DetourTransactionCommit(); From 999869304f32db6d505ad89af00402902de4e904 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 20:08:32 -0700 Subject: [PATCH 62/63] build(msvc): rename Multiview::Update's parameters off the members (#2626) /W4 reports C4458 three times at Multiview::Update's signature: `multiviewLayout`, `drawLabel` and `drawSafeArea` each redeclare a class member. The body only uses the names to assign the members, so the parameters take the names of what they carry and every later read keeps resolving to the member. Behaviour is identical; no flag, test or exemption change. --- frontend/components/Multiview.cpp.hpp | 8 ++++---- frontend/components/Multiview.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/components/Multiview.cpp.hpp b/frontend/components/Multiview.cpp.hpp index e91d0b4818..a71cd5abd1 100644 --- a/frontend/components/Multiview.cpp.hpp +++ b/frontend/components/Multiview.cpp.hpp @@ -50,11 +50,11 @@ static OBSSource CreateLabel(const char *name, size_t h) return txtSource.Get(); } -void Multiview::Update(MultiviewLayout multiviewLayout, bool drawLabel, bool drawSafeArea) +void Multiview::Update(MultiviewLayout layout, bool showLabel, bool showSafeArea) { - this->multiviewLayout = multiviewLayout; - this->drawLabel = drawLabel; - this->drawSafeArea = drawSafeArea; + this->multiviewLayout = layout; + this->drawLabel = showLabel; + this->drawSafeArea = showSafeArea; struct obs_video_info ovi; obs_get_video_info(&ovi); diff --git a/frontend/components/Multiview.hpp b/frontend/components/Multiview.hpp index c7382bdeb1..a6194f467a 100644 --- a/frontend/components/Multiview.hpp +++ b/frontend/components/Multiview.hpp @@ -21,7 +21,7 @@ class Multiview { public: Multiview(); ~Multiview(); - void Update(MultiviewLayout multiviewLayout, bool drawLabel, bool drawSafeArea); + void Update(MultiviewLayout layout, bool showLabel, bool showSafeArea); void Render(uint32_t cx, uint32_t cy); OBSSource GetSourceByPosition(int x, int y); From 779351559b02fef14862e5cbcc72027aa29986f5 Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Wed, 28 Oct 2026 20:24:42 -0700 Subject: [PATCH 63/63] build(msvc): rename the audio-control parameters that shadow their members (#2626) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wave 28 of the /W4 app lane: the mixer widget family reports C4458 at each parameter or local that redeclares a member, and C4456 at the group-insert loop variable in SourceTreeModel. | site | diagnostic | fix | | --- | --- | --- | | `OBSAdvAudioCtrl::percentChanged(int percent)` | C4458 (`QPointer percent`) | `newPercent`, header updated | | `SourceToolbar` undo lambda `const std::string &data` | C4458 (member `data`) | `settingsJson` | | `SourceTree` private settings `obs_data_t *data` | C4458 (member `data`) | `privateSettings` | | `SourceTree` `preUpdateScene`'s `void *data` | C4458 (member `data`) | `updateFn` | | `SourceTreeModel` group-insert loop `item` | C4456 (earlier `item`) | `groupItem` | | `VolumeControl::setLayoutVertical(bool vertical)` | C4458 (member `vertical`) | `verticalLayout` | | `VolumeControl::renameSource`'s `std::string uuid` | C4458 (member `uuid`) | `sourceUuid`, capture and `add_action` updated | | `VolumeControl` inner `prevName`, undo/redo `data` | C4456, C4458 ×2 | `nameToRestore`, `undoUuid`/`redoUuid` | | `VolumeControl` accessible name `sourceName` | C4458 (member `sourceName`) | `sourceLabel` | | `VolumeName::paintEvent`'s `indicatorWidth` | C4458 (member `indicatorWidth`) | `arrowWidth` | | `VolumeSlider::paintEvent`'s `tickColor` | C4458 (member `tickColor`) | `tickMarkColor` | Source-only renames: no test, flag or exemption change. `./lint` ok and `ci/test_msvc_warning_level.py` 15 tests OK. --- frontend/components/OBSAdvAudioCtrl.cpp.hpp | 4 +-- frontend/components/OBSAdvAudioCtrl.hpp | 2 +- frontend/components/SourceToolbar.cpp.hpp | 4 +-- frontend/components/SourceTree.cpp.hpp | 10 +++---- frontend/components/SourceTreeModel.cpp.hpp | 4 +-- frontend/components/VolumeControl.cpp.hpp | 29 +++++++++++---------- frontend/components/VolumeName.cpp.hpp | 6 ++--- frontend/components/VolumeSlider.cpp.hpp | 6 ++--- 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/frontend/components/OBSAdvAudioCtrl.cpp.hpp b/frontend/components/OBSAdvAudioCtrl.cpp.hpp index f400da9119..347d4ae555 100644 --- a/frontend/components/OBSAdvAudioCtrl.cpp.hpp +++ b/frontend/components/OBSAdvAudioCtrl.cpp.hpp @@ -389,10 +389,10 @@ void OBSAdvAudioCtrl::volumeChanged(double db) std::bind(undo_redo, std::placeholders::_1, val), uuid, uuid, true); } -void OBSAdvAudioCtrl::percentChanged(int percent) +void OBSAdvAudioCtrl::percentChanged(int newPercent) { float prev = obs_source_get_volume(source); - float val = (float)percent / 100.0f; + float val = (float)newPercent / 100.0f; obs_source_set_volume(source, val); diff --git a/frontend/components/OBSAdvAudioCtrl.hpp b/frontend/components/OBSAdvAudioCtrl.hpp index e194088a4f..c00c50bb09 100644 --- a/frontend/components/OBSAdvAudioCtrl.hpp +++ b/frontend/components/OBSAdvAudioCtrl.hpp @@ -81,7 +81,7 @@ public slots: void SetSourceName(QString newName); void volumeChanged(double db); - void percentChanged(int percent); + void percentChanged(int newPercent); void downmixMonoChanged(bool checked); void balanceChanged(int val); void syncOffsetChanged(int milliseconds); diff --git a/frontend/components/SourceToolbar.cpp.hpp b/frontend/components/SourceToolbar.cpp.hpp index 48b148361e..6c816776b9 100644 --- a/frontend/components/SourceToolbar.cpp.hpp +++ b/frontend/components/SourceToolbar.cpp.hpp @@ -30,8 +30,8 @@ void SourceToolbar::SetUndoProperties(obs_source_t *source, bool repeatable) return; } std::string scene_uuid = obs_source_get_uuid(currentSceneSource); - auto undo_redo = [scene_uuid = std::move(scene_uuid), main](const std::string &data) { - OBSDataAutoRelease settings = obs_data_create_from_json(data.c_str()); + auto undo_redo = [scene_uuid = std::move(scene_uuid), main](const std::string &settingsJson) { + OBSDataAutoRelease settings = obs_data_create_from_json(settingsJson.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(settings, "undo_suuid")); obs_source_reset_settings(source, settings); diff --git a/frontend/components/SourceTree.cpp.hpp b/frontend/components/SourceTree.cpp.hpp index b3541b1452..60ffb484c9 100644 --- a/frontend/components/SourceTree.cpp.hpp +++ b/frontend/components/SourceTree.cpp.hpp @@ -162,9 +162,9 @@ void SourceTree::dropEvent(QDropEvent *event) bool dropOnCollapsed = false; if (dropGroup) { - obs_data_t *data = obs_sceneitem_get_private_settings(dropGroup); - dropOnCollapsed = obs_data_get_bool(data, "collapsed"); - obs_data_release(data); + obs_data_t *privateSettings = obs_sceneitem_get_private_settings(dropGroup); + dropOnCollapsed = obs_data_get_bool(privateSettings, "collapsed"); + obs_data_release(privateSettings); } if (indicator == QAbstractItemView::BelowItem || indicator == QAbstractItemView::OnItem || @@ -378,8 +378,8 @@ void SourceTree::dropEvent(QDropEvent *event) using updateScene_t = decltype(updateScene); - auto preUpdateScene = [](void *data, obs_scene_t *) { - (*static_cast(data))(); + auto preUpdateScene = [](void *updateFn, obs_scene_t *) { + (*static_cast(updateFn))(); }; ignoreReorder = true; diff --git a/frontend/components/SourceTreeModel.cpp.hpp b/frontend/components/SourceTreeModel.cpp.hpp index 667e6b8a04..c504b91621 100644 --- a/frontend/components/SourceTreeModel.cpp.hpp +++ b/frontend/components/SourceTreeModel.cpp.hpp @@ -332,8 +332,8 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices) main->undo_s.push_disabled(); - for (obs_sceneitem_t *item : item_order) { - obs_sceneitem_select(item, false); + for (obs_sceneitem_t *groupItem : item_order) { + obs_sceneitem_select(groupItem, false); } hasGroups = true; diff --git a/frontend/components/VolumeControl.cpp.hpp b/frontend/components/VolumeControl.cpp.hpp index 43c7cbe811..1626cf31c4 100644 --- a/frontend/components/VolumeControl.cpp.hpp +++ b/frontend/components/VolumeControl.cpp.hpp @@ -226,13 +226,13 @@ void VolumeControl::obsSourceDestroy(void *data, calldata_t *) Qt::QueuedConnection); } -void VolumeControl::setLayoutVertical(bool vertical) +void VolumeControl::setLayoutVertical(bool verticalLayout) { QBoxLayout *newLayout = new QBoxLayout(QBoxLayout::TopToBottom); newLayout->setContentsMargins(0, 0, 0, 0); newLayout->setSpacing(0); - if (vertical) { + if (verticalLayout) { setMaximumWidth(110); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); @@ -502,17 +502,17 @@ void VolumeControl::renameSource() QAction *action = reinterpret_cast(sender()); OBSSource source = action->property("source").value(); - std::string uuid = obs_source_get_uuid(source); + std::string sourceUuid = obs_source_get_uuid(source); OBSBasic *main = OBSBasic::Get(); // Defer the rename dialog to avoid blocking the UI thread while the context menu is closing, which can cause issues on some platforms - QTimer::singleShot(0, main, [main, uuid]() { + QTimer::singleShot(0, main, [main, sourceUuid]() { if (!main) { return; } - OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); + OBSSourceAutoRelease source = obs_get_source_by_uuid(sourceUuid.c_str()); if (!source) { return; } @@ -544,19 +544,20 @@ void VolumeControl::renameSource() continue; } - std::string prevName(obs_source_get_name(source)); - auto undo = [prevName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); - obs_source_set_name(source, prevName.c_str()); + std::string nameToRestore(obs_source_get_name(source)); + auto undo = [nameToRestore](const std::string &undoUuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(undoUuid.c_str()); + obs_source_set_name(source, nameToRestore.c_str()); }; std::string editedName = name; - auto redo = [editedName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto redo = [editedName](const std::string &redoUuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(redoUuid.c_str()); obs_source_set_name(source, editedName.c_str()); }; - main->undo_s.add_action(QTStr("Undo.Rename").arg(name.c_str()), undo, redo, uuid, uuid); + main->undo_s.add_action(QTStr("Undo.Rename").arg(name.c_str()), undo, redo, sourceUuid, + sourceUuid); obs_source_set_name(source, name.c_str()); break; @@ -855,8 +856,8 @@ void VolumeControl::updateText() bool muted = obs_source_muted(source); const char *accTextLookup = muted ? "VolControl.SliderMuted" : "VolControl.SliderUnmuted"; - QString sourceName = obs_source_get_name(source); - QString accText = QTStr(accTextLookup).arg(sourceName); + QString sourceLabel = obs_source_get_name(source); + QString accText = QTStr(accTextLookup).arg(sourceLabel); slider->setAccessibleName(accText); } diff --git a/frontend/components/VolumeName.cpp.hpp b/frontend/components/VolumeName.cpp.hpp index bd05ea544c..125a16310d 100644 --- a/frontend/components/VolumeName.cpp.hpp +++ b/frontend/components/VolumeName.cpp.hpp @@ -148,11 +148,11 @@ void VolumeName::paintEvent(QPaintEvent *) QRect contentRect = style()->subElementRect(QStyle::SE_PushButtonContents, &opt, this); int paddingRight = opt.rect.right() - contentRect.right(); - int indicatorWidth = style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); + int arrowWidth = style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); QStyleOption arrowOpt = opt; - QRect arrowRect(opt.rect.right() - indicatorWidth - paddingRight / 2, - opt.rect.center().y() - indicatorWidth / 2, indicatorWidth, indicatorWidth); + QRect arrowRect(opt.rect.right() - arrowWidth - paddingRight / 2, opt.rect.center().y() - arrowWidth / 2, + arrowWidth, arrowWidth); arrowOpt.rect = arrowRect; painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, arrowOpt); diff --git a/frontend/components/VolumeSlider.cpp.hpp b/frontend/components/VolumeSlider.cpp.hpp index 23a1f6789d..af4e47c2de 100644 --- a/frontend/components/VolumeSlider.cpp.hpp +++ b/frontend/components/VolumeSlider.cpp.hpp @@ -29,7 +29,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) } QPainter painter(this); - QColor tickColor(91, 98, 115, 255); + QColor tickMarkColor(91, 98, 115, 255); obs_fader_conversion_t fader_db_to_def = obs_fader_db_to_def(fad); @@ -51,7 +51,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) float tickValue = fader_db_to_def(db); float xPos = groove.left() + (tickValue * sliderWidth) + (handle.width() / 2); - painter.fillRect(xPos, yPos, 1, tickLength, tickColor); + painter.fillRect(xPos, yPos, 1, tickLength, tickMarkColor); } } @@ -68,7 +68,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) float yPos = groove.height() + groove.top() - (tickValue * sliderHeight) - (handle.height() / 2); - painter.fillRect(xPos, yPos, tickLength, 1, tickColor); + painter.fillRect(xPos, yPos, tickLength, 1, tickMarkColor); } }