Revision: 29650
http://sourceforge.net/p/bibdesk/svn/29650
Author: hofman
Date: 2025-10-01 22:10:27 +0000 (Wed, 01 Oct 2025)
Log Message:
-----------
initWithCoder: should always be designated initializer
Modified Paths:
--------------
trunk/bibdesk/BDSKCondition.h
trunk/bibdesk/BDSKCondition.m
trunk/bibdesk/BDSKServerInfo.h
trunk/bibdesk/BDSKServerInfo.m
Modified: trunk/bibdesk/BDSKCondition.h
===================================================================
--- trunk/bibdesk/BDSKCondition.h 2025-10-01 16:14:34 UTC (rev 29649)
+++ trunk/bibdesk/BDSKCondition.h 2025-10-01 22:10:27 UTC (rev 29650)
@@ -118,7 +118,9 @@
@property (class, nonatomic, readonly) NSString *dictionaryVersion;
-- (nullable instancetype)initWithDictionary:(NSDictionary *)dictionary;
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
@property (nonatomic, readonly) NSDictionary *dictionaryValue;
Modified: trunk/bibdesk/BDSKCondition.m
===================================================================
--- trunk/bibdesk/BDSKCondition.m 2025-10-01 16:14:34 UTC (rev 29649)
+++ trunk/bibdesk/BDSKCondition.m 2025-10-01 22:10:27 UTC (rev 29650)
@@ -137,15 +137,28 @@
}
- (instancetype)initWithCoder:(NSCoder *)decoder {
- self = [self init];
+ self = [super init];
if (self) {
+ key = [decoder decodeObjectForKey:@"key"] ?: @"";
+ stringValue = @"";
+ stringComparison = BDSKContain;
+ attachmentComparison = BDSKCountNotEqual;
+ countValue = 0;
+ dateComparison = BDSKToday;
+ numberValue = 0;
+ andNumberValue = 0;
+ periodValue = BDSKPeriodDay;
+ dateValue = nil;
+ toDateValue = nil;
+ group = nil;
+ cachedStartDate = nil;
+ cachedEndDate = nil;
+ cacheTimer = nil;
// the order is important
- [self setKey:[decoder decodeObjectForKey:@"key"]];
[self setComparison:[decoder
decodeIntegerForKey:@"comparison"]];
if ([self isDateCondition] || [self isAttachmentCondition])
[self setDefaultValue];
[self setValue:[decoder decodeObjectForKey:@"value"]];
- BDSKASSERT(key != nil);
BDSKASSERT([self value] != nil);
}
return self;
Modified: trunk/bibdesk/BDSKServerInfo.h
===================================================================
--- trunk/bibdesk/BDSKServerInfo.h 2025-10-01 16:14:34 UTC (rev 29649)
+++ trunk/bibdesk/BDSKServerInfo.h 2025-10-01 22:10:27 UTC (rev 29650)
@@ -65,6 +65,7 @@
+ (nullable instancetype)defaultServerInfoWithType:(NSString *)aType;
- (nullable instancetype)initWithType:(NSString *)aType name:(NSString *)aName
database:(NSString *)aDbase host:(nullable NSString *)aHost port:(nullable
NSString *)aPort options:(nullable NSDictionary *)options
NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)init NS_UNAVAILABLE;
- (nullable instancetype)initWithDictionary:(NSDictionary *)info;
Modified: trunk/bibdesk/BDSKServerInfo.m
===================================================================
--- trunk/bibdesk/BDSKServerInfo.m 2025-10-01 16:14:34 UTC (rev 29649)
+++ trunk/bibdesk/BDSKServerInfo.m 2025-10-01 22:10:27 UTC (rev 29650)
@@ -106,8 +106,6 @@
name = [aName copy];
database = [aDbase copy];
passwordInKeychain = NO;
- if ([self isKindOfClass:[BDSKMutableServerInfo class]] == NO)
- passwordLock = [[BDSKReadWriteLock alloc] init];
if ([self isEntrez] || [self isISI] || [self isDBLP]) {
host = nil;
port = nil;
@@ -149,12 +147,30 @@
}
- (instancetype)initWithCoder:(NSCoder *)decoder {
- self = [self initWithType:[decoder decodeObjectForKey:TYPE_KEY]
- name:[decoder decodeObjectForKey:NAME_KEY]
- database:[decoder decodeObjectForKey:DATABASE_KEY]
- host:[decoder decodeObjectForKey:HOST_KEY]
- port:[decoder decodeObjectForKey:PORT_KEY]
- options:[decoder decodeObjectForKey:OPTIONS_KEY]];
+ self = [super init];
+ if (self) {
+ type = [decoder decodeObjectForKey:TYPE_KEY];
+ name = [decoder decodeObjectForKey:NAME_KEY];
+ database = [decoder decodeObjectForKey:DATABASE_KEY];
+ passwordInKeychain = NO;
+ if ([self isEntrez] || [self isISI] || [self isDBLP]) {
+ host = nil;
+ port = nil;
+ options = [[decoder decodeObjectForKey:OPTIONS_KEY] mutableCopy];
+ if ([options count] == 0)
+ options = nil;
+ password = [[options objectForKey:PASSWORD_KEY] copy];
+ [options removeObjectForKey:PASSWORD_KEY];
+ } else if ([self isZoom] || [self isSRU]) {
+ host = [decoder decodeObjectForKey:HOST_KEY];
+ port = [decoder decodeObjectForKey:PORT_KEY];
+ options = [[decoder decodeObjectForKey:OPTIONS_KEY] mutableCopy];
+ password = [[options objectForKey:PASSWORD_KEY] copy];
+ [options removeObjectForKey:PASSWORD_KEY];
+ } else {
+ self = nil;
+ }
+ }
return self;
}
@@ -403,6 +419,22 @@
return set;
}
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ passwordLock = nil;
+ }
+ return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+ self = [super initWithCoder:decoder];
+ if (self) {
+ passwordLock = nil;
+ }
+ return self;
+}
+
// When changing the type, all data must be properly updated to be valid,
taking into account the condition implict in the validation methods
- (void)setType:(NSString *)newType {
if ([type isEqualToString:newType] == NO) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit