From c2e3dcd8bf331c0753c7159192fce8e09fd1cc92 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 20 Apr 2020 11:08:22 +0100 Subject: [PATCH] Updated the documentation of some methods which now return std::unique_ptr instead of raw pointers to remove references to deleting the returned object --- .../format/juce_AudioPluginFormatManager.h | 2 -- modules/juce_core/containers/juce_PropertySet.h | 4 ++-- modules/juce_core/network/juce_URL.h | 6 +----- modules/juce_core/xml/juce_XmlDocument.h | 7 +++---- modules/juce_data_structures/values/juce_ValueTree.h | 1 - .../juce_gui_basics/commands/juce_KeyPressMappingSet.h | 2 -- modules/juce_gui_basics/drawables/juce_Drawable.h | 6 ++---- modules/juce_gui_basics/widgets/juce_TreeView.h | 4 ---- modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h | 9 ++------- 9 files changed, 10 insertions(+), 31 deletions(-) diff --git a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h index 83a5b1290d..5a7c4dd9a5 100644 --- a/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h +++ b/modules/juce_audio_processors/format/juce_AudioPluginFormatManager.h @@ -64,8 +64,6 @@ public: /** Tries to load the type for this description, by trying all the formats that this manager knows about. - The caller is responsible for deleting the object that is returned. - If it can't load the plugin, it returns nullptr and leaves a message in the errorMessage string. diff --git a/modules/juce_core/containers/juce_PropertySet.h b/modules/juce_core/containers/juce_PropertySet.h index be4a22b728..e0ef440403 100644 --- a/modules/juce_core/containers/juce_PropertySet.h +++ b/modules/juce_core/containers/juce_PropertySet.h @@ -104,8 +104,8 @@ public: /** Returns one of the properties as an XML element. - The result will a new XMLElement object that the caller must delete. If may return nullptr - if the key isn't found, or if the entry contains an string that isn't valid XML. + The result will a new XMLElement object. It may return nullptr if the key isn't found, + or if the entry contains an string that isn't valid XML. If the value isn't found in this set, then this will look for it in a fallback property set (if you've specified one with the setFallbackPropertySet() method), diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index aa671cb381..7f0a6b9192 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -337,8 +337,7 @@ public: returning a response (ignored for Android which follows up to 5 redirects) @param httpRequestCmd Specify which HTTP Request to use. If this is empty, then doPostRequest will determine the HTTP request. - @returns an input stream that the caller must delete, or a null pointer if there was an - error trying to open it. + @returns a valid input stream, or nullptr if there was an error trying to open it. */ std::unique_ptr createInputStream (bool doPostLikeRequest, OpenStreamProgressCallback* progressCallback = nullptr, @@ -479,9 +478,6 @@ public: If it fails, or if the text that it reads can't be parsed as XML, this will return nullptr. - When it returns a valid XmlElement object, the caller is responsible for deleting - this object when no longer needed. - Note that on some platforms (Android, for example) it's not permitted to do any network action from the message thread, so you must only call it from a background thread. diff --git a/modules/juce_core/xml/juce_XmlDocument.h b/modules/juce_core/xml/juce_XmlDocument.h index 0b200f051f..daa154d85c 100644 --- a/modules/juce_core/xml/juce_XmlDocument.h +++ b/modules/juce_core/xml/juce_XmlDocument.h @@ -93,8 +93,7 @@ public: allows quick checking of large files to see if they contain the correct type of tag, without having to parse the entire file - @returns a new XmlElement which the caller will need to delete, or null if - there was an error. + @returns a new XmlElement, or nullptr if there was an error. @see getLastParseError, getDocumentElementIfTagMatches */ std::unique_ptr getDocumentElement (bool onlyReadOuterDocumentElement = false); @@ -136,14 +135,14 @@ public: /** A handy static method that parses a file. This is a shortcut for creating an XmlDocument object and calling getDocumentElement() on it. An even better shortcut is the juce::parseXML() function, which returns a std::unique_ptr! - @returns a new XmlElement which the caller will need to delete, or null if there was an error. + @returns a new XmlElement, or nullptr if there was an error. */ static std::unique_ptr parse (const File& file); /** A handy static method that parses some XML data. This is a shortcut for creating an XmlDocument object and calling getDocumentElement() on it. An even better shortcut is the juce::parseXML() function, which returns a std::unique_ptr! - @returns a new XmlElement which the caller will need to delete, or null if there was an error. + @returns a new XmlElement, or nullptr if there was an error. */ static std::unique_ptr parse (const String& xmlData); diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index f4eb73f524..72d908c385 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -419,7 +419,6 @@ public: /** Creates an XmlElement that holds a complete image of this tree and all its children. If this tree is invalid, this may return nullptr. Otherwise, the XML that is produced can be used to recreate a similar tree by calling ValueTree::fromXml(). - The caller must delete the object that is returned. @see fromXml, toXmlString */ std::unique_ptr createXml() const; diff --git a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h index 369306ee47..299b94e5f0 100644 --- a/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h +++ b/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h @@ -186,8 +186,6 @@ public: This will produce a lump of XML that can be later reloaded using restoreFromXml() to recreate the current mapping state. - The object that is returned must be deleted by the caller. - @param saveDifferencesFromDefaultSet if this is false, then all keypresses will be saved into the XML. If it's true, then the XML will only store the differences between the current mappings and diff --git a/modules/juce_gui_basics/drawables/juce_Drawable.h b/modules/juce_gui_basics/drawables/juce_Drawable.h index daa4ce737c..3daac82b02 100644 --- a/modules/juce_gui_basics/drawables/juce_Drawable.h +++ b/modules/juce_gui_basics/drawables/juce_Drawable.h @@ -144,8 +144,7 @@ public: /** Attempts to parse an SVG (Scalable Vector Graphics) document, and to turn this into a Drawable tree. - The object returned must be deleted by the caller. If something goes wrong - while parsing, it may return nullptr. + If something goes wrong while parsing, it may return nullptr. SVG is a pretty large and complex spec, and this doesn't aim to be a full implementation, but it can return the basic vector objects. @@ -155,8 +154,7 @@ public: /** Attempts to parse an SVG (Scalable Vector Graphics) document from a file, and to turn this into a Drawable tree. - The object returned must be deleted by the caller. If something goes wrong - while parsing, it may return nullptr. + If something goes wrong while parsing, it may return nullptr. SVG is a pretty large and complex spec, and this doesn't aim to be a full implementation, but it can return the basic vector objects. diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index 5095def64e..c063bd5b91 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -499,8 +499,6 @@ public: for a specific item, but this can be handy if you need to briefly save the state for a section of the tree. - The caller is responsible for deleting the object that is returned. - Note that if all nodes of the tree are in their default state, then this may return a nullptr. @@ -796,8 +794,6 @@ public: completely different instance of the tree, as long as it contains nodes whose unique names are the same. - The caller is responsible for deleting the object that is returned. - @param alsoIncludeScrollPosition if this is true, the state will also include information about where the tree has been scrolled to vertically, diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h index cbcf455b0d..b703012b93 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h @@ -19,19 +19,14 @@ namespace juce { -/** Creates a graphics context object that will render into the given OpenGL target. - The caller is responsible for deleting this object when no longer needed. -*/ +/** Creates a graphics context object that will render into the given OpenGL target. */ std::unique_ptr createOpenGLGraphicsContext (OpenGLContext&, int width, int height); -/** Creates a graphics context object that will render into the given OpenGL framebuffer. - The caller is responsible for deleting this object when no longer needed. -*/ +/** Creates a graphics context object that will render into the given OpenGL framebuffer. */ std::unique_ptr createOpenGLGraphicsContext (OpenGLContext&, OpenGLFrameBuffer&); /** Creates a graphics context object that will render into the given OpenGL framebuffer, with the given size. - The caller is responsible for deleting this object when no longer needed. */ std::unique_ptr createOpenGLGraphicsContext (OpenGLContext&, unsigned int frameBufferID,