From bc027b52370cc6712cf77eb5bf066039707eb9cf Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 17 Oct 2018 09:41:01 +0100 Subject: [PATCH] Tidied up some spelling and comments --- .../format_types/juce_VST3PluginFormat.cpp | 7 ++++--- modules/juce_core/memory/juce_WeakReference.h | 18 ++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index fda384f3f2..dcd967bdb9 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2560,12 +2560,13 @@ private: bypassParam = param; std::function findOrCreateGroup; + findOrCreateGroup = [&groupMap, &infoMap, &findOrCreateGroup](Vst::UnitID groupID) { - auto existingGoup = groupMap.find (groupID); + auto existingGroup = groupMap.find (groupID); - if (existingGoup != groupMap.end()) - return existingGoup->second; + if (existingGroup != groupMap.end()) + return existingGroup->second; auto groupInfo = infoMap.find (groupID); diff --git a/modules/juce_core/memory/juce_WeakReference.h b/modules/juce_core/memory/juce_WeakReference.h index 62484211cc..166313b486 100644 --- a/modules/juce_core/memory/juce_WeakReference.h +++ b/modules/juce_core/memory/juce_WeakReference.h @@ -32,18 +32,16 @@ namespace juce It must embed a WeakReference::Master object, which stores a shared pointer object, and must clear this master pointer in its destructor. + Note that WeakReference is not designed to be thread-safe, so if you're accessing it from + different threads, you'll need to do your own locking around all uses of the pointer and + the object it refers to. + E.g. @code class MyObject { public: - MyObject() - { - // If you're planning on using your WeakReferences in a multi-threaded situation, you may choose - // to create a WeakReference to the object here in the constructor, which will pre-initialise the - // embedded object, avoiding an (extremely unlikely) race condition that could occur if multiple - // threads overlap while creating the first WeakReference to it. - } + MyObject() {} ~MyObject() { @@ -63,12 +61,12 @@ namespace juce // Here's an example of using a pointer.. - MyObject* n = new MyObject(); + auto* n = new MyObject(); WeakReference myObjectRef = n; - MyObject* pointer1 = myObjectRef; // returns a valid pointer to 'n' + auto pointer1 = myObjectRef.get(); // returns a valid pointer to 'n' delete n; - MyObject* pointer2 = myObjectRef; // returns a null pointer + auto pointer2 = myObjectRef.get(); // now returns nullptr @endcode @see WeakReference::Master