-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a crash on non-@objc String?
properties
#5783
Conversation
#5713 made it so that optional Swift properties of a supported data type (i.e. `String?` and object links) which do not have ivars due to not being declared as `@objc dynamic` would crash rather than merely fail to actually read and update the managed value when the property is used. The idea behavior here would be to throw an error on schema initialization as it's an invalid model declaration, but that's a breaking change (as such objects do work correctly when unmanaged), so for now this just restores the pre-3.5.0 behavior.
@@ -90,17 +90,24 @@ void RLMInitializeSwiftAccessorGenerics(__unsafe_unretained RLMObjectBase *const | |||
} | |||
|
|||
for (RLMProperty *prop in object->_objectSchema.swiftGenericProperties) { | |||
id ivar = object_getIvar(object, prop.swiftIvar); | |||
if (!ivar) { | |||
// FIXME: this should actually be an error as it's the result of an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue tracking this, so we remember fixing it for the next major version?
@@ -123,6 +123,10 @@ - (void)doesNotRecognizeSelector:(SEL)aSelector { | |||
} | |||
|
|||
id RLMGetOptional(__unsafe_unretained RLMOptionalBase *const self) { | |||
if (!self) { | |||
// FIXME: this should actually be an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Link to issue.
@@ -132,6 +136,10 @@ id RLMGetOptional(__unsafe_unretained RLMOptionalBase *const self) { | |||
} | |||
|
|||
void RLMSetOptional(__unsafe_unretained RLMOptionalBase *const self, __unsafe_unretained const id value) { | |||
if (!self) { | |||
// FIXME: this should actually be an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Link to issue.
#5713 made it so that optional Swift properties of a supported data type (i.e.
String?
and object links) which do not have ivars due to not being declared as@objc dynamic
would crash rather than merely fail to actually read and update the managed value when the property is used.The idea behavior here would be to throw an error on schema initialization as it's an invalid model declaration, but that's a breaking change (as such objects do work correctly when unmanaged), so for now this just restores the pre-3.5.0 behavior.
Fixes #5781.