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

ObjCClass: Remove virtual destructor and add move operations

ObjCClass doesn't have other virtual methods; it is not intended to be
used as an interface or dynamic type. Removing the virtual destructor
is intended to promote composition over inheritance when using this
type.
This commit is contained in:
reuk 2025-03-05 20:27:31 +00:00
parent 8799a73d6a
commit 1f4cc7bbb1
No known key found for this signature in database

View file

@ -317,7 +317,7 @@ struct ObjCClass
jassert (cls != nil);
}
virtual ~ObjCClass()
~ObjCClass()
{
auto kvoSubclassName = String ("NSKVONotifying_") + class_getName (cls);
@ -325,6 +325,16 @@ struct ObjCClass
objc_disposeClassPair (cls);
}
ObjCClass (ObjCClass&& other) noexcept
: cls (std::exchange (other.cls, {})) {}
ObjCClass& operator= (ObjCClass&& other) noexcept
{
auto tmp = std::move (other);
std::swap (tmp.cls, cls);
return *this;
}
void registerClass()
{
if (cls != nil)