diff --git a/modules/juce_core/containers/juce_DynamicObject.cpp b/modules/juce_core/containers/juce_DynamicObject.cpp index 38f5c5f081..3351f19b8e 100644 --- a/modules/juce_core/containers/juce_DynamicObject.cpp +++ b/modules/juce_core/containers/juce_DynamicObject.cpp @@ -45,7 +45,7 @@ bool DynamicObject::hasProperty (const Identifier& propertyName) const return v != nullptr && ! v->isMethod(); } -var DynamicObject::getProperty (const Identifier& propertyName) const +const var& DynamicObject::getProperty (const Identifier& propertyName) const { return properties [propertyName]; } diff --git a/modules/juce_core/containers/juce_DynamicObject.h b/modules/juce_core/containers/juce_DynamicObject.h index 5c624a4d9b..598df6ed62 100644 --- a/modules/juce_core/containers/juce_DynamicObject.h +++ b/modules/juce_core/containers/juce_DynamicObject.h @@ -60,7 +60,7 @@ public: /** Returns a named property. This returns var::null if no such property exists. */ - virtual var getProperty (const Identifier& propertyName) const; + virtual const var& getProperty (const Identifier& propertyName) const; /** Sets a named property. */ virtual void setProperty (const Identifier& propertyName, const var& newValue); diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index db3f2f5666..7943ab5dcf 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -576,15 +576,15 @@ var var::clone() const noexcept } //============================================================================== -var var::operator[] (const Identifier propertyName) const +const var& var::operator[] (Identifier propertyName) const { if (DynamicObject* const o = getDynamicObject()) return o->getProperty (propertyName); - return var(); + return var::null; } -var var::operator[] (const char* const propertyName) const +const var& var::operator[] (const char* const propertyName) const { return operator[] (Identifier (propertyName)); } diff --git a/modules/juce_core/containers/juce_Variant.h b/modules/juce_core/containers/juce_Variant.h index 41a4884c1c..1e0f03cf56 100644 --- a/modules/juce_core/containers/juce_Variant.h +++ b/modules/juce_core/containers/juce_Variant.h @@ -242,9 +242,9 @@ public: //============================================================================== /** If this variant is an object, this returns one of its properties. */ - var operator[] (Identifier propertyName) const; + const var& operator[] (Identifier propertyName) const; /** If this variant is an object, this returns one of its properties. */ - var operator[] (const char* propertyName) const; + const var& operator[] (const char* propertyName) const; /** If this variant is an object, this returns one of its properties, or a default fallback value if the property is not set. */ var getProperty (Identifier propertyName, const var& defaultReturnValue) const;