There was a change between Tiger and Leopard in the way NSPersistentDocument loaded its model.

If you have a document created on Tiger, the model is created using [NSManagedObjectModel mergedModelFromBundles: [NSBundle allBundles]], and on Leopard, with [NSManagedObjectModel mergedModelFromBundles: nil]. The problem with the first version is, as you've seen, as more and more frameworks start to include bundles, the model gets polluted with entities from things you don't care about.

There's a check done at runtime to see which version you were compiled on, so you get the same runtime behavior for applications that were compiled and linked on Tiger that depended on the original behavior, but if you recompile on Leopard, you get the later, safer behavior.

See:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPersistentDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPersistentDocument/managedObjectModel

Cheers,
+Melissa

On Dec 15, 2008, at 14:52, Houdah - ML Pierre Bernard wrote:

Hi!

I am puzzled! I have run into this weirdest problem. It only happens if I target Tiger.

I am working on an update to HoudahGeo and suddenly, my current build refuses to open documents. This includes both existing documents and documents created by the running application. The error is:

Error Domain=NSCocoaErrorDomain Code=134020 UserInfo=0x2b7b10 "The model configuration used to open the store is incompatible with the one that was used to create the store." NSUnderlyingException = Can't find table for entity MovieReference in database at URL file://localhost/Users/pierre/Desktop/HoudahGeo-Leopard.hgeo;

There is no MovieReference entity in the model. There never was. Actually I have seen the same message with varying entity names. I believe they are taken from other applications.

BTW, the model has not been updated in over a year. And most certainly not between saving and attempting to reopen using the same running application.

The stack is:

#0      0x96da7e17 in objc_exception_throw
#1      0x9496344b in -[NSSQLCore _ensureDatabaseMatchesModel]
#2      0x94962b35 in -[NSSQLCore load:]
#3 0x94958732 in -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] #4 0x915f5fe9 in -[NSPersistentDocument configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error :] #5 0x915f6fab in -[NSPersistentDocument (NSPersistentDocumentDeprecated) configurePersistentStoreCoordinatorForURL:ofType:error:]
#6      0x915f63b6 in -[NSPersistentDocument readFromURL:ofType:error:]
#7 0x000041c2 in -[Document readFromURL:ofType:error:] at Document.m: 177
#8      0x913f16c6 in -[NSDocument initWithContentsOfURL:ofType:error:]
#9 0x913c1274 in -[NSDocumentController makeDocumentWithContentsOfURL:ofType:error:] #10 0x913c0898 in -[NSDocumentController openDocumentWithContentsOfURL:display:error:]


This only happens when I target Tiger. When I target Leopard with the same code all works fine.
It occurs on both 10.5.5 and 10.5.6

When I compile an older version of the project, it works just fine. Thus I broke something with my recent changes. Yet I have no idea what. I did not touch the model.

Pierre
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mjturner%40apple.com

This email sent to mjtur...@apple.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to