adium 3682:5d5b68b95780: Setting properties on BOOLs or ints thi...
commits at adium.im
commits at adium.im
Tue Feb 22 21:37:51 UTC 2011
details: http://hg.adium.im/adium/rev/5d5b68b95780
revision: 3682:5d5b68b95780
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Tue Feb 22 22:37:43 2011 +0100
Setting properties on BOOLs or ints this way couldn't even work, it overwrites random data by inserting 64 bit values into too small objects.
Reverting the ESObjectWithProperties patch for anything but NSIntegers and pointers.
diffs (222 lines):
diff -r 4b75899e4e3a -r 5d5b68b95780 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Tue Feb 22 01:05:24 2011 +0100
+++ b/Adium.xcodeproj/project.pbxproj Tue Feb 22 22:37:43 2011 +0100
@@ -9551,7 +9551,6 @@
};
buildConfigurationList = DADE8E3A085507450062B664 /* Build configuration list for PBXProject "Adium" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
diff -r 4b75899e4e3a -r 5d5b68b95780 Frameworks/Adium Framework/Source/AIAccount.h
--- a/Frameworks/Adium Framework/Source/AIAccount.h Tue Feb 22 01:05:24 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIAccount.h Tue Feb 22 22:37:43 2011 +0100
@@ -247,17 +247,11 @@
NSString *formattedUID;
AIStatus *accountStatus;
- BOOL isConnecting;
NSDate *waitingToReconnect;
- BOOL isDisconnecting;
-
- BOOL isWaitingForNetwork;
NSInteger connectionProgressPercent;
NSString *connectionProgressString;
- BOOL mustPromptForPasswordOnNextConnect;
-
NSString *currentDisplayName;
}
diff -r 4b75899e4e3a -r 5d5b68b95780 Frameworks/Adium Framework/Source/AIChat.h
--- a/Frameworks/Adium Framework/Source/AIChat.h Tue Feb 22 01:05:24 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIChat.h Tue Feb 22 22:37:43 2011 +0100
@@ -133,8 +133,6 @@
NSDictionary *chatCreationInfo;
- BOOL accountJoined;
-
NSInteger unviewedMention;
NSInteger unviewedContent;
@@ -143,12 +141,9 @@
NSTimer *enteredTextTimer;
NSInteger ourTypingState;
- AITypingState typing;
NSDictionary *securityDetails;
- BOOL secureMessagingLastEncryptedState;
-
NSString *topic;
AIListContact *topicSetter;
}
diff -r 4b75899e4e3a -r 5d5b68b95780 Frameworks/Adium Framework/Source/AIListContact.h
--- a/Frameworks/Adium Framework/Source/AIListContact.h Tue Feb 22 01:05:24 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIListContact.h Tue Feb 22 22:37:43 2011 +0100
@@ -34,26 +34,17 @@
NSColor *labelColor;
NSNumber *imageOpacity;
- BOOL isEvent;
NSString *ABUniqueID;
NSAttributedString *textProfile;
- BOOL isBlocked;
- BOOL isIdle;
NSInteger idle;
NSDate *idleSince;
NSString *idleReadable;
- BOOL notAStranger;
- BOOL isMobile;
-
NSString *serverDisplayName;
NSString *formattedUID;
-
- BOOL signedOff;
- BOOL signedOn;
}
- (id)initWithUID:(NSString *)inUID account:(AIAccount *)inAccount service:(AIService *)inService;
diff -r 4b75899e4e3a -r 5d5b68b95780 Frameworks/Adium Framework/Source/AIListObject.h
--- a/Frameworks/Adium Framework/Source/AIListObject.h Tue Feb 22 01:05:24 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIListObject.h Tue Feb 22 22:37:43 2011 +0100
@@ -100,9 +100,6 @@
NSImage *listStateIcon;
NSImage *listStatusIcon;
- BOOL isOnline;
- BOOL alwaysVisible;
-
NSInteger unviewedContent;
NSInteger unviewedMention;
diff -r 4b75899e4e3a -r 5d5b68b95780 Frameworks/Adium Framework/Source/ESObjectWithProperties.m
--- a/Frameworks/Adium Framework/Source/ESObjectWithProperties.m Tue Feb 22 01:05:24 2011 +0100
+++ b/Frameworks/Adium Framework/Source/ESObjectWithProperties.m Tue Feb 22 22:37:43 2011 +0100
@@ -105,19 +105,6 @@
[oldValue release];
object_setIvar(self, ivar, [value retain]);
- } else if (strcmp(ivarType, @encode(BOOL)) == 0) {
-
- BOOL bValue;
-
- if (value) {
- bValue = [value boolValue];
- } else {
- bValue = FALSE;
- }
-
- // must cast twice to avoid gcc's warnings..
- object_setIvar(self, ivar, (void *)(NSInteger)bValue);
-
} else if (strcmp(ivarType, @encode(NSInteger)) == 0) {
NSInteger iValue;
@@ -130,17 +117,6 @@
object_setIvar(self, ivar, (void *)iValue);
- } else if (strcmp(ivarType, @encode(int)) == 0) {
-
- int iValue;
-
- if (value) {
- iValue = [(NSNumber *)value intValue];
- } else {
- iValue = 0;
- }
-
- object_setIvar(self, ivar, (void *)(NSInteger)iValue);
}
}
@@ -240,18 +216,10 @@
const char *ivarType = ivar_getTypeEncoding(ivar);
// attempt to wrap it, if we know how
- if (strcmp(ivarType, @encode(BOOL)) == 0) {
- ret = [[[NSNumber alloc] initWithBool:(BOOL)(NSInteger)value] autorelease];
-
- } else if (strcmp(ivarType, @encode(NSInteger)) == 0) {
+ if (strcmp(ivarType, @encode(NSInteger)) == 0) {
ret = [[[NSNumber alloc] initWithInteger:(NSInteger)value] autorelease];
-
- } else if (strcmp(ivarType, @encode(int)) == 0) {
- ret = [[[NSNumber alloc] initWithInt:(int)(NSInteger)value] autorelease];
-
} else if (ivarType[0] != _C_ID) {
- AILogWithSignature(@" *** This ivar is not an object but an %s! Should not use -valueForProperty: @\"%@\" ***", ivarType, key);
-
+ AILogWithBacktrace(@" *** This ivar is not an object but an %s! Should not use -valueForProperty: @\"%@\" ***", ivarType, key);
} else {
ret = [[value retain] autorelease];
}
@@ -292,21 +260,8 @@
{
int ret = 0;
- Ivar ivar = class_getInstanceVariable([self class], [key UTF8String]);
-
- if (ivar == NULL) {
- NSNumber *number = [self numberValueForProperty:key];
- ret = number ? [number intValue] : 0;
- } else {
-
- const char *ivarType = ivar_getTypeEncoding(ivar);
-
- if (strcmp(ivarType, @encode(int)) != 0) {
- AILogWithSignature(@"%@'s %@ ivar is not an int but an %s! Will attempt to cast, but should not use -intValueForProperty: @\"%@\"", self, key, ivarType, key);
- }
-
- ret = (int)(NSInteger)object_getIvar(self, ivar);
- }
+ NSNumber *number = [self numberValueForProperty:key];
+ ret = number ? [number intValue] : 0;
return ret;
}
@@ -315,21 +270,8 @@
{
BOOL ret = FALSE;
- Ivar ivar = class_getInstanceVariable([self class], [key UTF8String]);
-
- if (ivar == NULL) {
- NSNumber *number = [self numberValueForProperty:key];
- ret = number ? [number boolValue] : NO;
- } else {
-
- const char *ivarType = ivar_getTypeEncoding(ivar);
-
- if (strcmp(ivarType, @encode(BOOL)) != 0) {
- AILogWithSignature(@"%@'s %@ ivar is not an BOOL but an %s! Will attempt to cast, but should not use -boolValueForProperty: @\"%@\"", self, key, ivarType, key);
- }
-
- ret = (BOOL)(NSInteger)object_getIvar(self, ivar);
- }
+ NSNumber *number = [self numberValueForProperty:key];
+ ret = number ? [number boolValue] : NO;
return ret;
}
diff -r 4b75899e4e3a -r 5d5b68b95780 Plugins/WebKit Message View/AIWebKitMessageViewController.m
--- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m Tue Feb 22 01:05:24 2011 +0100
+++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m Tue Feb 22 22:37:43 2011 +0100
@@ -1446,7 +1446,7 @@
[self updateTopic];
// Tell the chat to set the topic.
- [chat setTopic:topicChange];
+ [chat setValue:topicChange forProperty:@"topic" notify:NotifyNow];
}
}
More information about the commits
mailing list