mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Marked as deprecated: String::empty, var::null, File::nonexistent, ValueTree::invalid and other problematic statically-initialised null values. Please just use the default constructor for these classes!
This commit is contained in:
parent
2e51654958
commit
8c38c6f57f
14 changed files with 53 additions and 61 deletions
|
|
@ -2006,8 +2006,7 @@ private:
|
|||
loopKindLabel { {}, "Looping Mode" };
|
||||
|
||||
|
||||
FileChooser fileChooser { "Select a file to load...",
|
||||
File::nonexistent,
|
||||
FileChooser fileChooser { "Select a file to load...", File(),
|
||||
dataModel.getAudioFormatManager().getWildcardForAllFormats() };
|
||||
|
||||
UndoManager* undoManager;
|
||||
|
|
|
|||
|
|
@ -435,9 +435,7 @@ var::var() noexcept : type (&VariantType_Void::instance) {}
|
|||
var::var (const VariantType& t) noexcept : type (&t) {}
|
||||
var::~var() noexcept { type->cleanUp (value); }
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const var var::null;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const var var::null);
|
||||
|
||||
//==============================================================================
|
||||
var::var (const var& valueToCopy) : type (valueToCopy.type)
|
||||
|
|
|
|||
|
|
@ -274,17 +274,15 @@ public:
|
|||
*/
|
||||
static var readFromStream (InputStream& input);
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty var object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need a default-constructed var, just use var() or {}.
|
||||
The only time you might miss having var::null available might be if you need to return an
|
||||
empty var from a function by reference, but if you need to do that, it's easy enough to use
|
||||
a function-local static var and return that, avoiding any order-of-initialisation issues.
|
||||
/* This was a static empty var object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need a default-constructed var, just use var() or {}.
|
||||
The only time you might miss having var::null available might be if you need to return an
|
||||
empty var from a function by reference, but if you need to do that, it's easy enough to use
|
||||
a function-local static var and return that, avoiding any order-of-initialisation issues.
|
||||
*/
|
||||
static const var null;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const var null);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ File& File::operator= (File&& other) noexcept
|
|||
return *this;
|
||||
}
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const File File::nonexistent;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent);
|
||||
|
||||
//==============================================================================
|
||||
static String removeEllipsis (const String& path)
|
||||
|
|
|
|||
|
|
@ -1048,21 +1048,14 @@ public:
|
|||
bool foldersFirst;
|
||||
};
|
||||
|
||||
#if (! defined(DOXYGEN)) && (! defined (JUCE_GCC))
|
||||
// Deprecated: use File::getSeparatorChar() and File::getSeparatorString() instead!
|
||||
JUCE_DEPRECATED (static const juce_wchar separator);
|
||||
JUCE_DEPRECATED (static const StringRef separatorString);
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty File object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need a default-constructed File object, just use File() or {}.
|
||||
/* These static objects are deprecated because it's too easy to accidentally use them indirectly
|
||||
during a static constructor, which leads to very obscure order-of-initialisation bugs.
|
||||
Use File::getSeparatorChar() and File::getSeparatorString(), and instead of File::nonexistent,
|
||||
just use File() or {}.
|
||||
*/
|
||||
static const File nonexistent;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const juce_wchar separator);
|
||||
JUCE_DEPRECATED_STATIC (static const StringRef separatorString);
|
||||
JUCE_DEPRECATED_STATIC (static const File nonexistent);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -273,6 +273,28 @@ namespace juce
|
|||
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body) functionDef body
|
||||
#endif
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
#if ! (defined (DOXYGEN) || defined (JUCE_GCC) || (JUCE_MSVC && _MSC_VER <= 1900))
|
||||
#define JUCE_DEPRECATED_STATIC(valueDef) JUCE_DEPRECATED (valueDef)
|
||||
|
||||
#if JUCE_MSVC
|
||||
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable:4996)) \
|
||||
valueDef \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef
|
||||
#endif
|
||||
#else
|
||||
#define JUCE_DEPRECATED_STATIC(valueDef) valueDef
|
||||
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef) valueDef
|
||||
#endif
|
||||
#else
|
||||
#define JUCE_DEPRECATED_STATIC(valueDef)
|
||||
#define JUCE_DECLARE_DEPRECATED_STATIC(valueDef)
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ANDROID && ! DOXYGEN
|
||||
#define JUCE_MODAL_LOOPS_PERMITTED 0
|
||||
|
|
|
|||
|
|
@ -235,9 +235,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const String String::empty;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const String String::empty);
|
||||
|
||||
//==============================================================================
|
||||
String::String() noexcept : text (&(emptyString.text))
|
||||
|
|
|
|||
|
|
@ -1239,8 +1239,7 @@ public:
|
|||
int getReferenceCount() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** This was a static empty string object, but is now deprecated as it's too easy to accidentally
|
||||
/* This was a static empty string object, but is now deprecated as it's too easy to accidentally
|
||||
use it indirectly during a static constructor, leading to hard-to-find order-of-initialisation
|
||||
problems.
|
||||
@deprecated If you need an empty String object, just use String() or {}.
|
||||
|
|
@ -1248,8 +1247,7 @@ public:
|
|||
empty string from a function by reference, but if you need to do that, it's easy enough to use
|
||||
a function-local static String object and return that, avoiding any order-of-initialisation issues.
|
||||
*/
|
||||
static const String empty;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const String empty);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -579,9 +579,7 @@ ValueTree::ValueTree() noexcept
|
|||
{
|
||||
}
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const ValueTree ValueTree::invalid;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const ValueTree ValueTree::invalid);
|
||||
|
||||
ValueTree::ValueTree (const Identifier& type) : object (new ValueTree::SharedObject (type))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -589,12 +589,10 @@ public:
|
|||
*/
|
||||
int getReferenceCount() const noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** An invalid ValueTree that can be used if you need to return one as an error condition, etc.
|
||||
/* An invalid ValueTree that can be used if you need to return one as an error condition, etc.
|
||||
@deprecated If you need an empty ValueTree object, just use ValueTree() or {}.
|
||||
*/
|
||||
static const ValueTree invalid;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const ValueTree invalid);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ bool AffineTransform::isIdentity() const noexcept
|
|||
&& mat11 == 1.0f;
|
||||
}
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const AffineTransform AffineTransform::identity;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const AffineTransform AffineTransform::identity);
|
||||
|
||||
//==============================================================================
|
||||
AffineTransform AffineTransform::followedBy (const AffineTransform& other) const noexcept
|
||||
|
|
|
|||
|
|
@ -270,12 +270,10 @@ public:
|
|||
*/
|
||||
float getScaleFactor() const noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A ready-to-use identity transform - now depracated.
|
||||
@deprecated If you need an identity transform, just use AffineTransform() or {}.
|
||||
/* A ready-to-use identity transform - now depracated.
|
||||
@deprecated If you need an identity transform, just use AffineTransform() or {}.
|
||||
*/
|
||||
static const AffineTransform identity;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const AffineTransform identity);
|
||||
|
||||
//==============================================================================
|
||||
/* The transform matrix is:
|
||||
|
|
|
|||
|
|
@ -262,9 +262,7 @@ Image::~Image()
|
|||
{
|
||||
}
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
const Image Image::null;
|
||||
#endif
|
||||
JUCE_DECLARE_DEPRECATED_STATIC (const Image Image::null);
|
||||
|
||||
int Image::getReferenceCount() const noexcept { return image == nullptr ? 0 : image->getSharedCount(); }
|
||||
int Image::getWidth() const noexcept { return image == nullptr ? 0 : image->width; }
|
||||
|
|
|
|||
|
|
@ -414,12 +414,10 @@ public:
|
|||
/** @internal */
|
||||
explicit Image (ImagePixelData*) noexcept;
|
||||
|
||||
#if JUCE_ALLOW_STATIC_NULL_VARIABLES
|
||||
/** A null Image object that can be used when you need to return an invalid image.
|
||||
/* A null Image object that can be used when you need to return an invalid image.
|
||||
@deprecated If you need a default-constructed var, just use Image() or {}.
|
||||
*/
|
||||
static const Image null;
|
||||
#endif
|
||||
JUCE_DEPRECATED_STATIC (static const Image null);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue