mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-23 01:44:22 +00:00
Added some missing copy and move constructors in the ReferenceCountedObject classes
This commit is contained in:
parent
82648926c6
commit
eca20d1e4a
1 changed files with 27 additions and 19 deletions
|
|
@ -99,6 +99,15 @@ protected:
|
|||
/** Creates the reference-counted object (with an initial ref count of zero). */
|
||||
ReferenceCountedObject() {}
|
||||
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
ReferenceCountedObject (const ReferenceCountedObject&) noexcept {}
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
ReferenceCountedObject (ReferenceCountedObject&&) noexcept {}
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
ReferenceCountedObject& operator= (const ReferenceCountedObject&) noexcept { return *this; }
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
ReferenceCountedObject& operator= (ReferenceCountedObject&&) noexcept { return *this; }
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~ReferenceCountedObject()
|
||||
{
|
||||
|
|
@ -116,10 +125,8 @@ protected:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
Atomic <int> refCount;
|
||||
|
||||
Atomic<int> refCount { 0 };
|
||||
friend struct ContainerDeletePolicy<ReferenceCountedObject>;
|
||||
JUCE_DECLARE_NON_COPYABLE (ReferenceCountedObject)
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -176,7 +183,16 @@ public:
|
|||
protected:
|
||||
//==============================================================================
|
||||
/** Creates the reference-counted object (with an initial ref count of zero). */
|
||||
SingleThreadedReferenceCountedObject() : refCount (0) {}
|
||||
SingleThreadedReferenceCountedObject() {}
|
||||
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
SingleThreadedReferenceCountedObject (const SingleThreadedReferenceCountedObject&) {}
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
SingleThreadedReferenceCountedObject (SingleThreadedReferenceCountedObject&&) {}
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
SingleThreadedReferenceCountedObject& operator= (const SingleThreadedReferenceCountedObject&) { return *this; }
|
||||
/** Copying from another object does not affect this one's reference-count. */
|
||||
SingleThreadedReferenceCountedObject& operator= (SingleThreadedReferenceCountedObject&&) { return *this; }
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~SingleThreadedReferenceCountedObject()
|
||||
|
|
@ -187,10 +203,8 @@ protected:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
int refCount;
|
||||
|
||||
int refCount = 0;
|
||||
friend struct ContainerDeletePolicy<ReferenceCountedObject>;
|
||||
JUCE_DECLARE_NON_COPYABLE (SingleThreadedReferenceCountedObject)
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -225,10 +239,10 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Creates a pointer to a null object. */
|
||||
ReferenceCountedObjectPtr() noexcept
|
||||
: referencedObject (nullptr)
|
||||
{
|
||||
}
|
||||
ReferenceCountedObjectPtr() noexcept {}
|
||||
|
||||
/** Creates a pointer to a null object. */
|
||||
ReferenceCountedObjectPtr (decltype (nullptr)) noexcept {}
|
||||
|
||||
/** Creates a pointer to an object.
|
||||
This will increment the object's reference-count.
|
||||
|
|
@ -239,12 +253,6 @@ public:
|
|||
incIfNotNull (refCountedObject);
|
||||
}
|
||||
|
||||
/** Creates a pointer to a null object. */
|
||||
ReferenceCountedObjectPtr (decltype (nullptr)) noexcept
|
||||
: referencedObject (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/** Copies another pointer.
|
||||
This will increment the object's reference-count.
|
||||
*/
|
||||
|
|
@ -293,7 +301,7 @@ public:
|
|||
if (referencedObject != newObject)
|
||||
{
|
||||
incIfNotNull (newObject);
|
||||
ReferencedType* const oldObject = referencedObject;
|
||||
auto* oldObject = referencedObject;
|
||||
referencedObject = newObject;
|
||||
decIfNotNull (oldObject);
|
||||
}
|
||||
|
|
@ -349,7 +357,7 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
ReferencedType* referencedObject;
|
||||
ReferencedType* referencedObject = nullptr;
|
||||
|
||||
static void incIfNotNull (ReferencedType* o) noexcept
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue