Closed MerlinDE closed 1 year ago
Hmmm, I'm mobile at the moment but is there any reason these changes couldn't just be deferring to load_or_register?
(Appreciate the contribution and can look more tomorrow, just commenting off the cuff right now)
Good point! Let me check and refactor.
Refactored using load_or_register_class
Nice! So this works for your expected use-case?
If you could do a formatting pass it'd be great, just to satisfy CI - I'll need to find time to look into why the iOS examples are currently breaking...
Heya - just wanted to confirm: this change still fixes the issue you were encountering?
Yes, it does fix my issue.
This can happen in environments like plugins, where cacao can exist multiple times and thus tries to create and register its objc classes more than once.
I'm using cacao to implement interface elements in Adobe Illustrator plugins. Whenever I had more than one of those added in parallel to Illustrator, it crashed. Reason was, that the objc classes for the interface elements like button, label or image were registered multiple times. This lead to a
None
returned that wasunwrap()
in a panic.This code just checks if a to-be-registered class already exists and if so, returns it. Obviously, it can't change any added elements and just assumes we want to register the same class.
I didn't touch the
fn load_or_register_class()
, as this seems to already handle the situation.