mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Bug fix: Change improper usage of dot notation.
Calling methods which are not properties through use of dot notation is a no-no in Apple's Objective-C 2.0 documentation. According to Apple it might work but the compiler will not warn about any dangerous use cases. The prominent example from the docs of how not to do it is "someObject.retain". Here retain is a method and not a property so proper use is "[someObject retain]". Unfortunately, often it is not clear if something in the API is merely an accessor or a method which acts like an accessor but does more than the name might imply. In this case, we can see this in PBEasyPipe where we have method calls like "NSTask.standardOutput = ...". Even though they may look correct this can be dangerous for obvious reasons. I assume hat this could also play a role in the appearance of the "bad file descriptor" messages.
This commit is contained in:
@@ -13,9 +13,12 @@
|
||||
#define CONN_TIMEOUT 5
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
#import <objc/objc-auto.h> /* for objc_collect */
|
||||
|
||||
@implementation NSFileHandle(NSFileHandleExt)
|
||||
|
||||
-(NSString*)readLine {
|
||||
|
||||
// If the socket is closed, return an empty string
|
||||
if ([self fileDescriptor] <= 0)
|
||||
return @"";
|
||||
@@ -62,6 +65,8 @@
|
||||
retVal = [NSString stringWithCString: buffer encoding: NSISOLatin1StringEncoding];
|
||||
|
||||
free(buffer);
|
||||
|
||||
[[NSGarbageCollector defaultCollector] collectExhaustively];
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user