Skip to content

Commit

Permalink
Bugfix: cleanup didn't unswizzle classes that had already been swizzled
Browse files Browse the repository at this point in the history
This would happen when using other code that itself swizzles classes (i.e. ReactiveCocoa). For example, if a rac_signalForSelector was called on an object then later an aspect hook was installed and further removed, we would end up in a situation where Aspect's class swizzling (in-place swizzling of -forwardInvocation:) would never be ununstalled when the last hook was removed, later wrecking havoc with RAC's own use of -forwardInvocation.

In short, this pull request fixes hair-pulling crashes.
  • Loading branch information
fpillet committed Mar 31, 2015
1 parent b05702a commit 7d2cdf5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Aspects.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ static void aspect_cleanupHookedClassAndSelector(NSObject *self, SEL selector) {
// Class is most likely swizzled in place. Undo that.
if (isMetaClass) {
aspect_undoSwizzleClassInPlace((Class)self);
}else if (self.class != klass) {
aspect_undoSwizzleClassInPlace(klass);
}
}
}
Expand Down

0 comments on commit 7d2cdf5

Please sign in to comment.