1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-22 01:34:21 +00:00

Added the JUCE_DECLARE_WEAK_REFERENCEABLE macro to ValueWithDefault and fixed some places which were potentially accessing a deleted ValueWithDefault object

This commit is contained in:
ed 2018-11-16 15:53:29 +00:00
parent e786f9c0aa
commit 717cc49382
7 changed files with 38 additions and 11 deletions

View file

@ -131,11 +131,17 @@ public:
var getValue() const override
{
return valueWithDefault->isUsingDefault() ? var() : valueWithDefault->get();
if (valueWithDefault == nullptr || valueWithDefault->isUsingDefault())
return {};
return valueWithDefault->get();
}
void setValue (const var& newValue) override
{
if (valueWithDefault == nullptr)
return;
if (newValue.toString().isEmpty())
valueWithDefault->resetToDefault();
else
@ -143,7 +149,7 @@ public:
}
private:
ValueWithDefault* valueWithDefault = nullptr;
WeakReference<ValueWithDefault> valueWithDefault;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RemapperValueSourceWithDefault)