From ecdd3af90ae920e0028fdd733cc971be1a38d222 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Mon, 23 Feb 2026 14:15:53 -0500 Subject: [PATCH] Replace implicit lamda captures for C++20 Implicit capture of 'this' with a capture default of '=' is deprecated in C++20. While the standard recommends replacing '=' with '=, this', that syntax is not C++17 compatible, and we will likely need some transition period where obs-studio and its modules are still built using C++17. --- obs-browser-source.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp index 6e80fbce8..d8d10558e 100644 --- a/obs-browser-source.cpp +++ b/obs-browser-source.cpp @@ -171,7 +171,7 @@ void BrowserSource::ExecuteOnBrowser(BrowserFunc func, bool async) #ifdef ENABLE_BROWSER_QT_LOOP QueueBrowserTask(cefBrowser, func); #else - QueueCEFTask([=]() { func(browser); }); + QueueCEFTask([func, browser]() { func(browser); }); #endif } } @@ -257,7 +257,7 @@ void BrowserSource::SendMouseClick(const struct obs_mouse_event *event, int32_t int32_t y = event->y; ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [modifiers, x, y, type, mouse_up, click_count](CefRefPtr cefBrowser) { CefMouseEvent e; e.modifiers = modifiers; e.x = x; @@ -275,7 +275,7 @@ void BrowserSource::SendMouseMove(const struct obs_mouse_event *event, bool mous int32_t y = event->y; ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [modifiers, x, y, mouse_leave](CefRefPtr cefBrowser) { CefMouseEvent e; e.modifiers = modifiers; e.x = x; @@ -292,7 +292,7 @@ void BrowserSource::SendMouseWheel(const struct obs_mouse_event *event, int x_de int32_t y = event->y; ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [modifiers, x, y, x_delta, y_delta](CefRefPtr cefBrowser) { CefMouseEvent e; e.modifiers = modifiers; e.x = x; @@ -304,7 +304,7 @@ void BrowserSource::SendMouseWheel(const struct obs_mouse_event *event, int x_de void BrowserSource::SendFocus(bool focus) { - ExecuteOnBrowser([=](CefRefPtr cefBrowser) { cefBrowser->GetHost()->SetFocus(focus); }, true); + ExecuteOnBrowser([focus](CefRefPtr cefBrowser) { cefBrowser->GetHost()->SetFocus(focus); }, true); } void BrowserSource::SendKeyClick(const struct obs_key_event *event, bool key_up) @@ -326,7 +326,7 @@ void BrowserSource::SendKeyClick(const struct obs_key_event *event, bool key_up) #endif ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [native_vkey, key_up, text, modifiers](CefRefPtr cefBrowser) { CefKeyEvent e; e.windows_key_code = native_vkey; #ifdef __APPLE__ @@ -375,7 +375,7 @@ void BrowserSource::SetShowing(bool showing) } } else { ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [showing](CefRefPtr cefBrowser) { CefRefPtr msg = CefProcessMessage::Create("Visibility"); CefRefPtr args = msg->GetArgumentList(); args->SetBool(0, showing); @@ -409,7 +409,7 @@ void BrowserSource::SetShowing(bool showing) void BrowserSource::SetActive(bool active) { ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [active](CefRefPtr cefBrowser) { CefRefPtr msg = CefProcessMessage::Create("Active"); CefRefPtr args = msg->GetArgumentList(); args->SetBool(0, active); @@ -512,7 +512,7 @@ void BrowserSource::Update(obs_data_t *settings) width = n_width; height = n_height; ExecuteOnBrowser( - [=](CefRefPtr cefBrowser) { + [this](CefRefPtr cefBrowser) { const CefSize cefSize(width, height); cefBrowser->GetHost()->GetClient()->GetDisplayHandler()->OnAutoResize( cefBrowser, cefSize); @@ -659,7 +659,7 @@ static void ExecuteOnAllBrowsers(BrowserFunc func) void DispatchJSEvent(std::string eventName, std::string jsonString, BrowserSource *browser) { - const auto jsEvent = [=](CefRefPtr cefBrowser) { + const auto jsEvent = [eventName, jsonString](CefRefPtr cefBrowser) { CefRefPtr msg = CefProcessMessage::Create("DispatchJSEvent"); CefRefPtr args = msg->GetArgumentList();