diff -r 5ffe4647b1a2 src/joystick/iphoneos/SDL_mfijoystick.m --- a/src/joystick/iphoneos/SDL_mfijoystick.m Sat Nov 21 14:13:26 2020 -0800 +++ b/src/joystick/iphoneos/SDL_mfijoystick.m Sun Nov 22 13:23:22 2020 -0700 @@ -59,6 +59,16 @@ #include #include +/* Helpful macros + */ +#if __has_feature(objc_arc) +#define WEAK_SELF() __weak typeof(self) weakSelf = self +#define STRONG_SELF() typeof(self) _this = weakSelf +#else +#define WEAK_SELF() typeof(self) weakSelf = self +#define STRONG_SELF() typeof(self) _this = weakSelf +#endif + /* remove compilation warnings for strict builds by defining these selectors, even though * they are only ever used indirectly through objc_msgSend */ @@ -1057,9 +1067,9 @@ return nil; } - __weak typeof(self) weakSelf = self; + WEAK_SELF(); self->engine.stoppedHandler = ^(CHHapticEngineStoppedReason stoppedReason) { - SDL_RumbleMotor *_this = weakSelf; + STRONG_SELF(); if (_this == nil) { return; } @@ -1068,7 +1078,7 @@ _this->engine = nil; }; self->engine.resetHandler = ^{ - SDL_RumbleMotor *_this = weakSelf; + STRONG_SELF(); if (_this == nil) { return; }