Tuukka Norri  committed ce6947e

Bug fixes
- Made BXNetServiceConnector replace the URI only if it changes when setting the host. Otherwise, the entity descriptions which the context has already passed around might become invalid.
- Also made BXSynchronizedArrayController get its entity only when needed instead of at connection time.

  • Participants
  • Parent commits 7b22fca

Comments (0)

Files changed (2)

File BaseTenAppKit/Sources/BXNetServiceConnector.m

 		//Complete the database URI. If we're allowed to use the Keychain, try to fetch some credentials.
 		//If none are found, display the authentication panel. Otherwise connect.
-		//Don't use -setDatabaseURIInternal: because we just got a new host name.
 		NSURL* oldURI = [mContext databaseURI];
 		NSURL* newURI = [oldURI BXURIForHost: mHostName
 										port: (-1 == mPort ? nil : [NSNumber numberWithInteger: mPort])
 									database: nil
 									username: nil
 									password: nil];
-		[mContext setDatabaseURI: newURI];
+		//Don't use -setDatabaseURIInternal: because we just got a new host name.
+		//If old URI already contains the host name, the context might already
+		//have given entity descriptions, and we don't want to replace the object model.
+		if (! [oldURI isEqual: newURI])
+			[mContext setDatabaseURI: newURI];
 		if ([mContext usesKeychain])
             [mContext fetchPasswordFromKeychain];

File BaseTenAppKit/Sources/BXSynchronizedArrayController.m

         databaseContext = [ctx retain];
 		if (nil != databaseContext)
-		{            
-            //Also set the entity description, since the database URI has changed.
-			if (nil != [self tableName] && [databaseContext canGiveEntities])
-				[self prepareEntity];
+		{
+			[self setEntityDescription: nil];
 			[[databaseContext notificationCenter] addObserver: self selector: @selector (endConnecting:) name: kBXConnectionSuccessfulNotification object: databaseContext];