mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-06-19 01:56:29 +08:00
Fixing crash from over-release of RKParams.
This commit is contained in:
@@ -92,6 +92,11 @@
|
||||
}
|
||||
|
||||
- (void)deleteCachedObjectsMissingFromResult:(RKObjectMappingResult*)result {
|
||||
if (! [self isGET]) {
|
||||
RKLogDebug(@"Skipping cleanup of objects via managed object cache: only used for GET requests.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self.URL isKindOfClass:[RKURL class]]) {
|
||||
RKURL* rkURL = (RKURL*)self.URL;
|
||||
|
||||
|
||||
@@ -192,13 +192,16 @@ NSString* const kRKStringBoundary = @"0xKhTmLbOuNdArY";
|
||||
}
|
||||
|
||||
- (void)close {
|
||||
_streamStatus = NSStreamStatusClosed;
|
||||
RKLogTrace(@"RKParams stream closed. Releasing self.");
|
||||
|
||||
// NOTE: When we are assigned to the URL request, we get
|
||||
// retained. We release ourselves here to ensure the retain
|
||||
// count will hit zero after upload is complete.
|
||||
[self release];
|
||||
if (_streamStatus != NSStreamStatusClosed) {
|
||||
_streamStatus = NSStreamStatusClosed;
|
||||
|
||||
RKLogTrace(@"RKParams stream closed. Releasing self.");
|
||||
|
||||
// NOTE: When we are assigned to the URL request, we get
|
||||
// retained. We release ourselves here to ensure the retain
|
||||
// count will hit zero after upload is complete.
|
||||
[self release];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSStreamStatus)streamStatus {
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
25432041125618F000A315CF /* RKParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 25432040125618F000A315CF /* RKParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
25432064125632A300A315CF /* RKJSONParserYAJL.m in Sources */ = {isa = PBXBuildFile; fileRef = 253A08B71255212300976E89 /* RKJSONParserYAJL.m */; };
|
||||
25432065125632AA00A315CF /* RKJSONParserSBJSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 253A08B61255212300976E89 /* RKJSONParserSBJSON.m */; };
|
||||
2559209713BD1B8700E9C29C /* RKParamsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 2559208213BD1A4000E9C29C /* RKParamsSpec.m */; };
|
||||
255DE05E10FFA05800A85891 /* RKHuman.m in Sources */ = {isa = PBXBuildFile; fileRef = 255DE05D10FFA05800A85891 /* RKHuman.m */; };
|
||||
255DE0E210FFABA500A85891 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 255DE0E110FFABA500A85891 /* CoreData.framework */; };
|
||||
255DE0F410FFAC0A00A85891 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 255DE0F310FFAC0A00A85891 /* SystemConfiguration.framework */; };
|
||||
@@ -479,6 +480,7 @@
|
||||
253E04C413798D72005D2E15 /* RKErrorMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKErrorMessage.m; sourceTree = "<group>"; };
|
||||
25431EBA1255640800A315CF /* CoreData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreData.h; sourceTree = "<group>"; };
|
||||
25432040125618F000A315CF /* RKParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKParser.h; sourceTree = "<group>"; };
|
||||
2559208213BD1A4000E9C29C /* RKParamsSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RKParamsSpec.m; sourceTree = "<group>"; };
|
||||
255DE05C10FFA05800A85891 /* RKHuman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RKHuman.h; sourceTree = "<group>"; };
|
||||
255DE05D10FFA05800A85891 /* RKHuman.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKHuman.m; sourceTree = "<group>"; };
|
||||
255DE0E110FFABA500A85891 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||
@@ -1346,6 +1348,7 @@
|
||||
259D56B4132E706D00897272 /* RKAuthenticationSpec.m */,
|
||||
250C296B13411E60000A3551 /* RKRequestQueueSpec.m */,
|
||||
25ACF1AC13BB9D480067B380 /* RKURLSpec.m */,
|
||||
2559208213BD1A4000E9C29C /* RKParamsSpec.m */,
|
||||
);
|
||||
path = Network;
|
||||
sourceTree = "<group>";
|
||||
@@ -2116,6 +2119,7 @@
|
||||
25AA85D613B1065000A95E2A /* RKObjectLoaderSpec.m in Sources */,
|
||||
2515E7BD13B36AC100E013A4 /* RKObjectLoaderSpecResultModel.m in Sources */,
|
||||
25ACF1AD13BB9D490067B380 /* RKURLSpec.m in Sources */,
|
||||
2559209713BD1B8700E9C29C /* RKParamsSpec.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -78,22 +78,22 @@
|
||||
<EnvironmentVariable
|
||||
key = "UISPEC_EXIT_ON_FINISH"
|
||||
value = "NO"
|
||||
isEnabled = "NO">
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "NO">
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "UISPEC_SPEC"
|
||||
value = "RKObjectSerializerSpec"
|
||||
value = "RKParamsSpec"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "UISPEC_EXAMPLE"
|
||||
value = "itShouldSetAnErrorAndReturnNilIfItCantSerialize"
|
||||
isEnabled = "YES">
|
||||
isEnabled = "NO">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "NSAutoreleaseHaltOnNoPool"
|
||||
|
||||
34
Specs/Network/RKParamsSpec.m
Normal file
34
Specs/Network/RKParamsSpec.m
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// RKParamsSpec.m
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 6/30/11.
|
||||
// Copyright 2011 Two Toasters. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RKSpecEnvironment.h"
|
||||
#import "RKParams.h"
|
||||
#import "RKRequest.h"
|
||||
|
||||
@interface RKParamsSpec : RKSpec
|
||||
|
||||
@end
|
||||
|
||||
@implementation RKParamsSpec
|
||||
|
||||
- (void)itShouldNotOverReleaseTheParams {
|
||||
RKLogConfigureByName("RestKit/Network*", RKLogLevelTrace);
|
||||
NSDictionary* dictionary = [NSDictionary dictionaryWithObject:@"foo" forKey:@"bar"];
|
||||
RKParams* params = [[RKParams alloc] initWithDictionary:dictionary];
|
||||
NSURL* URL = [NSURL URLWithString:[RKSpecGetBaseURL() stringByAppendingFormat:@"/echo_params"]];
|
||||
RKSpecResponseLoader* responseLoader = [RKSpecResponseLoader responseLoader];
|
||||
RKRequest* request = [[RKRequest alloc] initWithURL:URL];
|
||||
request.method = RKRequestMethodPOST;
|
||||
request.params = params;
|
||||
request.delegate = responseLoader;
|
||||
[request sendAsynchronously];
|
||||
[responseLoader waitForResponse];
|
||||
[request release];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user