Skip to content

Commit

Permalink
解决由于get方法中的autorelease导致的崩溃的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFruity committed Feb 3, 2021
1 parent 853950b commit 70241ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OCRunner/RunEnv/MFValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ extern BOOL MFStatementResultTypeIsReturn(MFStatementResultType type);
@property (assign, nonatomic, readonly) double doubleValue;

@property (nonatomic, nullable, readonly) id objectValue;
@property (nonatomic, nullable, readonly) Class classValue;
@property (nonatomic, nullable, readonly) void *classValue;
@property (nonatomic, nullable, readonly) SEL selValue;
@property (nonatomic, nullable, readonly) char *cStringValue;

Expand Down
4 changes: 2 additions & 2 deletions OCRunner/RunEnv/MFValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ - (double)doubleValue{
- (id)objectValue{
return *(__strong id *)self.pointer;
}
- (Class)classValue{
return *(Class *)self.pointer;
- (void *)classValue{
return *(void **)self.pointer;
}
- (SEL)selValue{
return *(SEL *)self.pointer;
Expand Down
4 changes: 1 addition & 3 deletions OCRunner/RunnerClasses+Reverse.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ - (void)deallocffiReusltForKey:(NSValue *)key{
}
}
- (void)reverse{
MFValue *classValue = [[MFScopeChain topScope] recursiveGetValueWithIdentifier:self.className];
Class classVar = classValue.classValue;
Class class = NSClassFromString(self.className);
// Reverse时,释放ffi_closure和ffi_type
for (ORMethodImplementation *imp in self.methods) {
Expand All @@ -77,7 +75,7 @@ - (void)reverse{
[[MFMethodMapTable shareInstance] removeMethodsForClass:class];
[[MFPropertyMapTable shareInstance] removePropertiesForClass:class];

// FIXME: 真机下,调用后崩溃的问题
Class classVar = [[MFScopeChain topScope] recursiveGetValueWithIdentifier:self.className].classValue;
if (classVar != nil && classVar == class) {
objc_disposeClassPair(classVar);
}
Expand Down

0 comments on commit 70241ea

Please sign in to comment.