From 02c614563fda165a3a8bb3b55218ccb156c27554 Mon Sep 17 00:00:00 2001 From: apistol78 Date: Thu, 13 Jun 2024 16:06:44 +0200 Subject: [PATCH] Traktor: Updated more C++20 lambdas. --- code/Core/System/Win32/ProcessWin32.cpp | 2 +- code/Core/Thread/JobQueue.cpp | 2 +- .../Remote/Server/ConnectionManager.cpp | 2 +- code/Editor/App/BrowseInstanceDialog.cpp | 2 +- code/Editor/App/EditorForm.cpp | 26 +++++++++---------- .../Avalanche/AvalanchePipelineCache.cpp | 2 +- code/Jungle/OnlinePeer2PeerProvider.cpp | 2 +- code/Net/Discovery/DiscoveryManager.cpp | 2 +- code/Net/Stream/StreamServer.cpp | 2 +- code/Online/Impl/TaskQueue.cpp | 2 +- .../Server/Editor/RemoteEditorPlugin.cpp | 2 +- .../Shader/Facades/CommentNodeFacade.cpp | 4 +-- .../Shader/Facades/ScalarNodeFacade.cpp | 4 +-- .../Shader/Facades/SwizzleNodeFacade.cpp | 4 +-- .../Shader/Facades/UniformNodeFacade.cpp | 4 +-- .../Shader/Facades/VariableNodeFacade.cpp | 4 +-- code/Runtime/Editor/EditorPlugin.cpp | 4 +-- code/Runtime/Impl/Application.cpp | 4 +-- code/Runtime/Impl/ScriptServer.cpp | 2 +- code/Shape/Editor/Bake/TracerProcessor.cpp | 2 +- code/Sound/AudioSystem.cpp | 4 +-- code/Spray/EmitterInstance.cpp | 2 +- code/Video/VideoTexture.cpp | 2 +- 23 files changed, 43 insertions(+), 43 deletions(-) diff --git a/code/Core/System/Win32/ProcessWin32.cpp b/code/Core/System/Win32/ProcessWin32.cpp index f33368337..483c5c0c0 100644 --- a/code/Core/System/Win32/ProcessWin32.cpp +++ b/code/Core/System/Win32/ProcessWin32.cpp @@ -25,7 +25,7 @@ class PipeStream : public IStream , m_hPipe(hPipe) { ThreadPool::getInstance().spawn( - [this]() { threadPipeReader(); }, + [=, this]() { threadPipeReader(); }, m_thread ); } diff --git a/code/Core/Thread/JobQueue.cpp b/code/Core/Thread/JobQueue.cpp index 15f455506..64a163925 100644 --- a/code/Core/Thread/JobQueue.cpp +++ b/code/Core/Thread/JobQueue.cpp @@ -31,7 +31,7 @@ bool JobQueue::create(uint32_t workerThreads, Thread::Priority priority) for (uint32_t i = 0; i < uint32_t(m_workerThreads.size()); ++i) { m_workerThreads[i] = ThreadManager::getInstance().create( - [this]() { threadWorker(); }, + [=, this]() { threadWorker(); }, L"Job queue, worker thread" ); if (m_workerThreads[i]) diff --git a/code/Database/Remote/Server/ConnectionManager.cpp b/code/Database/Remote/Server/ConnectionManager.cpp index e6c17cca8..6db37f65b 100644 --- a/code/Database/Remote/Server/ConnectionManager.cpp +++ b/code/Database/Remote/Server/ConnectionManager.cpp @@ -48,7 +48,7 @@ bool ConnectionManager::create() m_listenPort = dynamic_type_cast< net::SocketAddressIPv4* >(m_listenSocket->getLocalAddress())->getPort(); m_serverThread = ThreadManager::getInstance().create( - [this](){ threadServer(); }, + [=, this](){ threadServer(); }, L"Database server" ); if (!m_serverThread) diff --git a/code/Editor/App/BrowseInstanceDialog.cpp b/code/Editor/App/BrowseInstanceDialog.cpp index c9254f29c..dbce0ebc3 100644 --- a/code/Editor/App/BrowseInstanceDialog.cpp +++ b/code/Editor/App/BrowseInstanceDialog.cpp @@ -134,7 +134,7 @@ bool BrowseInstanceDialog::create(ui::Widget* parent, db::Database* database, co // Spawn preview generator thread. ThreadPool::getInstance().spawn( - [this](){ threadGeneratePreview(); }, + [=, this](){ threadGeneratePreview(); }, m_threadGeneratePreview ); diff --git a/code/Editor/App/EditorForm.cpp b/code/Editor/App/EditorForm.cpp index f495a1ef0..3d85ccf06 100644 --- a/code/Editor/App/EditorForm.cpp +++ b/code/Editor/App/EditorForm.cpp @@ -1039,8 +1039,8 @@ Ref< db::Instance > EditorForm::browseInstance(const IBrowseFilter* filter) bool EditorForm::openEditor(db::Instance* instance) { T_ANONYMOUS_VAR(EnterLeave)( - [this](){ setCursor(ui::Cursor::Wait); }, - [this](){ resetCursor(); } + [=, this](){ setCursor(ui::Cursor::Wait); }, + [=, this](){ resetCursor(); } ); T_ASSERT(instance); @@ -1201,8 +1201,8 @@ bool EditorForm::openEditor(db::Instance* instance) bool EditorForm::openDefaultEditor(db::Instance* instance) { T_ANONYMOUS_VAR(EnterLeave)( - [this](){ setCursor(ui::Cursor::Wait); }, - [this](){ resetCursor(); } + [=, this](){ setCursor(ui::Cursor::Wait); }, + [=, this](){ resetCursor(); } ); T_ASSERT(instance); @@ -1241,8 +1241,8 @@ bool EditorForm::openDefaultEditor(db::Instance* instance) bool EditorForm::openInNewEditor(db::Instance* instance) { T_ANONYMOUS_VAR(EnterLeave)( - [this]() { setCursor(ui::Cursor::Wait); }, - [this]() { resetCursor(); } + [=, this]() { setCursor(ui::Cursor::Wait); }, + [=, this]() { resetCursor(); } ); T_ASSERT(instance); @@ -1538,7 +1538,7 @@ bool EditorForm::openWorkspace(const Path& workspacePath) updateTitle(); // Create asset monitor thread. - m_threadAssetMonitor = ThreadManager::getInstance().create([this](){ threadAssetMonitor(); }, L"Asset monitor"); + m_threadAssetMonitor = ThreadManager::getInstance().create([=, this](){ threadAssetMonitor(); }, L"Asset monitor"); m_threadAssetMonitor->start(); log::info << L"Workspace opened successfully." << Endl; @@ -1860,8 +1860,8 @@ void EditorForm::buildAsset(const Guid& assetGuid, bool rebuild) void EditorForm::buildAssets(bool rebuild) { T_ANONYMOUS_VAR(EnterLeave)( - [this](){ setCursor(ui::Cursor::Wait); }, - [this](){ resetCursor(); } + [=, this](){ setCursor(ui::Cursor::Wait); }, + [=, this](){ resetCursor(); } ); if (!m_workspaceSettings) @@ -2110,8 +2110,8 @@ void EditorForm::moveNewTabGroup() void EditorForm::saveCurrentDocument() { T_ANONYMOUS_VAR(EnterLeave)( - [this](){ setCursor(ui::Cursor::Wait); }, - [this](){ resetCursor(); } + [=, this](){ setCursor(ui::Cursor::Wait); }, + [=, this](){ resetCursor(); } ); // First iterate all object editor dialogs to see if focus is in any of those, @@ -2225,8 +2225,8 @@ void EditorForm::saveAsCurrentDocument() void EditorForm::saveAllDocuments() { T_ANONYMOUS_VAR(EnterLeave)( - [this](){ setCursor(ui::Cursor::Wait); }, - [this](){ resetCursor(); } + [=, this](){ setCursor(ui::Cursor::Wait); }, + [=, this](){ resetCursor(); } ); bool allSuccessfull = true; diff --git a/code/Editor/Pipeline/Avalanche/AvalanchePipelineCache.cpp b/code/Editor/Pipeline/Avalanche/AvalanchePipelineCache.cpp index d3bc9dcac..3d055928a 100644 --- a/code/Editor/Pipeline/Avalanche/AvalanchePipelineCache.cpp +++ b/code/Editor/Pipeline/Avalanche/AvalanchePipelineCache.cpp @@ -132,7 +132,7 @@ void AvalanchePipelineCache::getInformation(OutputStream& os) if (m_statsJob == nullptr) { - m_statsJob = JobManager::getInstance().add([this](){ + m_statsJob = JobManager::getInstance().add([=, this](){ m_client->stats(m_stats); }); } diff --git a/code/Jungle/OnlinePeer2PeerProvider.cpp b/code/Jungle/OnlinePeer2PeerProvider.cpp index 01a429c14..98eacc090 100644 --- a/code/Jungle/OnlinePeer2PeerProvider.cpp +++ b/code/Jungle/OnlinePeer2PeerProvider.cpp @@ -42,7 +42,7 @@ OnlinePeer2PeerProvider::OnlinePeer2PeerProvider(online::ISessionManager* sessio // Create transmission thread. if (asyncTx || asyncRx) { - if (!ThreadPool::getInstance().spawn([this](){ transmissionThread(); }, m_thread)) + if (!ThreadPool::getInstance().spawn([=, this](){ transmissionThread(); }, m_thread)) { m_thread = nullptr; m_asyncTx = diff --git a/code/Net/Discovery/DiscoveryManager.cpp b/code/Net/Discovery/DiscoveryManager.cpp index b3f31dd23..5508053ed 100644 --- a/code/Net/Discovery/DiscoveryManager.cpp +++ b/code/Net/Discovery/DiscoveryManager.cpp @@ -85,7 +85,7 @@ bool DiscoveryManager::create(uint32_t mode) log::info << L"Discovery manager: receive address " << m_replyToAddress << L"." << Endl; // Create communication thread. - m_threadMulticastListener = ThreadManager::getInstance().create([this](){ threadMulticastListener(); }, L"Discovery listener"); + m_threadMulticastListener = ThreadManager::getInstance().create([=, this](){ threadMulticastListener(); }, L"Discovery listener"); if (!m_threadMulticastListener) { log::error << L"Discovery setup failed; unable to create listener thread." << Endl; diff --git a/code/Net/Stream/StreamServer.cpp b/code/Net/Stream/StreamServer.cpp index b86631fc2..742431870 100644 --- a/code/Net/Stream/StreamServer.cpp +++ b/code/Net/Stream/StreamServer.cpp @@ -45,7 +45,7 @@ bool StreamServer::create() m_listenPort = dynamic_type_cast< net::SocketAddressIPv4* >(m_listenSocket->getLocalAddress())->getPort(); - m_serverThread = ThreadManager::getInstance().create([this](){ threadServer(); }, L"Stream server"); + m_serverThread = ThreadManager::getInstance().create([=, this](){ threadServer(); }, L"Stream server"); if (!m_serverThread) return false; diff --git a/code/Online/Impl/TaskQueue.cpp b/code/Online/Impl/TaskQueue.cpp index d0091535d..e7678a73e 100644 --- a/code/Online/Impl/TaskQueue.cpp +++ b/code/Online/Impl/TaskQueue.cpp @@ -21,7 +21,7 @@ T_IMPLEMENT_RTTI_CLASS(L"traktor.online.TaskQueue", TaskQueue, Object) bool TaskQueue::create() { - m_thread = ThreadManager::getInstance().create([this](){ threadQueue(); }, L"Online task queue"); + m_thread = ThreadManager::getInstance().create([=, this](){ threadQueue(); }, L"Online task queue"); if (!m_thread || !m_thread->start()) return false; diff --git a/code/Remote/Server/Editor/RemoteEditorPlugin.cpp b/code/Remote/Server/Editor/RemoteEditorPlugin.cpp index 28e5edc06..fa647f4e9 100644 --- a/code/Remote/Server/Editor/RemoteEditorPlugin.cpp +++ b/code/Remote/Server/Editor/RemoteEditorPlugin.cpp @@ -45,7 +45,7 @@ bool RemoteEditorPlugin::create(editor::IEditor* editor, ui::Widget* parent, edi return false; } - m_threadServer = ThreadManager::getInstance().create([this](){ threadServer(); }, L"Remote server"); + m_threadServer = ThreadManager::getInstance().create([=, this](){ threadServer(); }, L"Remote server"); m_threadServer->start(); return true; } diff --git a/code/Render/Editor/Shader/Facades/CommentNodeFacade.cpp b/code/Render/Editor/Shader/Facades/CommentNodeFacade.cpp index 21a2c8e5b..2891a2d6b 100644 --- a/code/Render/Editor/Shader/Facades/CommentNodeFacade.cpp +++ b/code/Render/Editor/Shader/Facades/CommentNodeFacade.cpp @@ -74,7 +74,7 @@ void CommentNodeFacade::editShaderNode( m_edit = new ui::Edit(); m_edit->create(graphControl); m_edit->addEventHandler< ui::FocusEvent >( - [this](ui::FocusEvent* event) + [=, this](ui::FocusEvent* event) { if (m_edit->isVisible(false) && event->lostFocus()) { @@ -85,7 +85,7 @@ void CommentNodeFacade::editShaderNode( } ); m_edit->addEventHandler< ui::KeyDownEvent >( - [this](ui::KeyDownEvent* event) + [=, this](ui::KeyDownEvent* event) { if (event->getVirtualKey() == ui::VkReturn) { diff --git a/code/Render/Editor/Shader/Facades/ScalarNodeFacade.cpp b/code/Render/Editor/Shader/Facades/ScalarNodeFacade.cpp index 04bb658e0..83837a809 100644 --- a/code/Render/Editor/Shader/Facades/ScalarNodeFacade.cpp +++ b/code/Render/Editor/Shader/Facades/ScalarNodeFacade.cpp @@ -90,7 +90,7 @@ void ScalarNodeFacade::editShaderNode( m_edit = new ui::Edit(); m_edit->create(graphControl, L"", ui::WsNone, new ui::NumericEditValidator(true)); m_edit->addEventHandler< ui::FocusEvent >( - [this](ui::FocusEvent* event) + [=, this](ui::FocusEvent* event) { if (m_edit->isVisible(false) && event->lostFocus()) { @@ -101,7 +101,7 @@ void ScalarNodeFacade::editShaderNode( } ); m_edit->addEventHandler< ui::KeyDownEvent >( - [this](ui::KeyDownEvent* event) + [=, this](ui::KeyDownEvent* event) { if (event->getVirtualKey() == ui::VkReturn) { diff --git a/code/Render/Editor/Shader/Facades/SwizzleNodeFacade.cpp b/code/Render/Editor/Shader/Facades/SwizzleNodeFacade.cpp index 66debe416..2ce51e517 100644 --- a/code/Render/Editor/Shader/Facades/SwizzleNodeFacade.cpp +++ b/code/Render/Editor/Shader/Facades/SwizzleNodeFacade.cpp @@ -98,7 +98,7 @@ void SwizzleNodeFacade::editShaderNode( m_edit = new ui::Edit(); m_edit->create(graphControl); m_edit->addEventHandler< ui::FocusEvent >( - [this](ui::FocusEvent* event) + [=, this](ui::FocusEvent* event) { if (m_edit->isVisible(false) && event->lostFocus()) { @@ -109,7 +109,7 @@ void SwizzleNodeFacade::editShaderNode( } ); m_edit->addEventHandler< ui::KeyDownEvent >( - [this](ui::KeyDownEvent* event) + [=, this](ui::KeyDownEvent* event) { if (event->getVirtualKey() == ui::VkReturn) { diff --git a/code/Render/Editor/Shader/Facades/UniformNodeFacade.cpp b/code/Render/Editor/Shader/Facades/UniformNodeFacade.cpp index be47a8f19..2d0f3bba4 100644 --- a/code/Render/Editor/Shader/Facades/UniformNodeFacade.cpp +++ b/code/Render/Editor/Shader/Facades/UniformNodeFacade.cpp @@ -98,7 +98,7 @@ void UniformNodeFacade::editShaderNode( m_edit = new ui::Edit(); m_edit->create(graphControl); m_edit->addEventHandler< ui::FocusEvent >( - [this](ui::FocusEvent* event) + [=, this](ui::FocusEvent* event) { if (m_edit->isVisible(false) && event->lostFocus()) { @@ -109,7 +109,7 @@ void UniformNodeFacade::editShaderNode( } ); m_edit->addEventHandler< ui::KeyDownEvent >( - [this](ui::KeyDownEvent* event) + [=, this](ui::KeyDownEvent* event) { if (event->getVirtualKey() == ui::VkReturn) { diff --git a/code/Render/Editor/Shader/Facades/VariableNodeFacade.cpp b/code/Render/Editor/Shader/Facades/VariableNodeFacade.cpp index adf260a50..ca094db1d 100644 --- a/code/Render/Editor/Shader/Facades/VariableNodeFacade.cpp +++ b/code/Render/Editor/Shader/Facades/VariableNodeFacade.cpp @@ -100,7 +100,7 @@ void VariableNodeFacade::editShaderNode( m_edit = new ui::Edit(); m_edit->create(graphControl); m_edit->addEventHandler< ui::FocusEvent >( - [this](ui::FocusEvent* event) + [=, this](ui::FocusEvent* event) { if (m_edit->isVisible(false) && event->lostFocus()) { @@ -111,7 +111,7 @@ void VariableNodeFacade::editShaderNode( } ); m_edit->addEventHandler< ui::KeyDownEvent >( - [this](ui::KeyDownEvent* event) + [=, this](ui::KeyDownEvent* event) { if (event->getVirtualKey() == ui::VkReturn) { diff --git a/code/Runtime/Editor/EditorPlugin.cpp b/code/Runtime/Editor/EditorPlugin.cpp index 2e66c450f..837139569 100644 --- a/code/Runtime/Editor/EditorPlugin.cpp +++ b/code/Runtime/Editor/EditorPlugin.cpp @@ -210,10 +210,10 @@ bool EditorPlugin::create(editor::IEditor* editor, ui::Widget* parent, editor::I m_site->createAdditionalPanel(m_splitter, 200_ut, false); // Create threads. - m_threadHostEnumerator = ThreadManager::getInstance().create([this](){ threadHostEnumerator(); }, L"Host enumerator"); + m_threadHostEnumerator = ThreadManager::getInstance().create([=, this](){ threadHostEnumerator(); }, L"Host enumerator"); m_threadHostEnumerator->start(); - m_threadTargetActions = ThreadManager::getInstance().create([this](){ threadTargetActions(); }, L"Targets"); + m_threadTargetActions = ThreadManager::getInstance().create([=, this](){ threadTargetActions(); }, L"Targets"); m_threadTargetActions->start(); return true; diff --git a/code/Runtime/Impl/Application.cpp b/code/Runtime/Impl/Application.cpp index b5573f78d..b03fbdc85 100644 --- a/code/Runtime/Impl/Application.cpp +++ b/code/Runtime/Impl/Application.cpp @@ -303,7 +303,7 @@ bool Application::create( if (settings->getProperty< bool >(L"Runtime.DatabaseThread", false)) { T_DEBUG(L"Creating database monitoring thread..."); - m_threadDatabase = ThreadManager::getInstance().create([this](){ threadDatabase(); }, L"Database events"); + m_threadDatabase = ThreadManager::getInstance().create([=, this](){ threadDatabase(); }, L"Database events"); if (m_threadDatabase) m_threadDatabase->start(Thread::Highest); } @@ -363,7 +363,7 @@ bool Application::create( settings->getProperty< bool >(L"Runtime.RenderThread", true) ) { - m_threadRender = ThreadManager::getInstance().create([this](){ threadRender(); }, L"Render"); + m_threadRender = ThreadManager::getInstance().create([=, this](){ threadRender(); }, L"Render"); if (m_threadRender) { #if defined(__IOS__) diff --git a/code/Runtime/Impl/ScriptServer.cpp b/code/Runtime/Impl/ScriptServer.cpp index 58c7296ca..b9062bd24 100644 --- a/code/Runtime/Impl/ScriptServer.cpp +++ b/code/Runtime/Impl/ScriptServer.cpp @@ -104,7 +104,7 @@ bool ScriptServer::create( { m_transport = transport; - m_scriptDebuggerThread = ThreadManager::getInstance().create([this](){ threadDebugger(); }, L"Script debugger/profiler thread"); + m_scriptDebuggerThread = ThreadManager::getInstance().create([=, this](){ threadDebugger(); }, L"Script debugger/profiler thread"); if (!m_scriptDebuggerThread) return false; diff --git a/code/Shape/Editor/Bake/TracerProcessor.cpp b/code/Shape/Editor/Bake/TracerProcessor.cpp index 6189630c9..3a3d4544b 100644 --- a/code/Shape/Editor/Bake/TracerProcessor.cpp +++ b/code/Shape/Editor/Bake/TracerProcessor.cpp @@ -272,7 +272,7 @@ TracerProcessor::TracerProcessor(const TypeInfo* rayTracerType, const std::wstri { T_FATAL_ASSERT(m_rayTracerType != nullptr); - m_thread = ThreadManager::getInstance().create([this](){ processorThread(); }, L"Tracer"); + m_thread = ThreadManager::getInstance().create([=, this](){ processorThread(); }, L"Tracer"); m_thread->start(); //if (!m_editor) diff --git a/code/Sound/AudioSystem.cpp b/code/Sound/AudioSystem.cpp index c0fd4e098..908396075 100644 --- a/code/Sound/AudioSystem.cpp +++ b/code/Sound/AudioSystem.cpp @@ -84,7 +84,7 @@ bool AudioSystem::create(const AudioSystemCreateDesc& desc) m_samplesBlocks.push_back(&m_samplesData[i * samplesPerBlock]); // Create mixer and submission threads. - m_threadMixer = ThreadManager::getInstance().create([this](){ threadMixer(); }, L"Sound mixer", 1); + m_threadMixer = ThreadManager::getInstance().create([=, this](){ threadMixer(); }, L"Sound mixer", 1); if (!m_threadMixer) { m_driver->destroy(); @@ -209,7 +209,7 @@ void AudioSystem::resume() // Create threads. if (!m_threadMixer) { - m_threadMixer = ThreadManager::getInstance().create([this](){ threadMixer(); }, L"Sound mixer", 1); + m_threadMixer = ThreadManager::getInstance().create([=, this](){ threadMixer(); }, L"Sound mixer", 1); if (!m_threadMixer) return; } diff --git a/code/Spray/EmitterInstance.cpp b/code/Spray/EmitterInstance.cpp index f04bd75c6..dfea72160 100644 --- a/code/Spray/EmitterInstance.cpp +++ b/code/Spray/EmitterInstance.cpp @@ -343,7 +343,7 @@ void EmitterInstance::updateTask(float deltaTime) m_skip < 4 ) { - std::sort(m_renderPoints.begin(), m_renderPoints.end(), [this](const Point& lh, const Point& rh) { + std::sort(m_renderPoints.begin(), m_renderPoints.end(), [=, this](const Point& lh, const Point& rh) { return (bool)(m_sortPlane.distance(lh.position) > m_sortPlane.distance(rh.position)); }); } diff --git a/code/Video/VideoTexture.cpp b/code/Video/VideoTexture.cpp index 027eea26b..af1c5de84 100644 --- a/code/Video/VideoTexture.cpp +++ b/code/Video/VideoTexture.cpp @@ -57,7 +57,7 @@ bool VideoTexture::create(render::IRenderSystem* renderSystem, IVideoDecoder* de m_timer.reset(); - if (!ThreadPool::getInstance().spawn([this](){ decodeThread(); }, m_thread)) + if (!ThreadPool::getInstance().spawn([=, this](){ decodeThread(); }, m_thread)) return false; return true;