marcoarment / FCModel

An alternative to Core Data for people who like having direct SQL access.
MIT License
1.65k stars 173 forks source link

Crash when calling +dataWasUpdatedExternally #69

Closed hartbit closed 10 years ago

hartbit commented 10 years ago

Here's a quick rundown of the crash:

  1. +dataWasUpdatedExternally is called after a custom importing operation
  2. If at least one of the classes has no loaded instances, postChangeNotification:changedFields:instance: is called with the instance parameter set to nil.
  3. In postChangeNotification:changedFields:instance:, a nil value on instance results in a lock initialized with NULL.
  4. dispatch_semaphore_wait is called with lock at NULL.
  5. Crash!

I would have done a pull request, but I'm not sure how this should be fixed. Should we avoid calling -postChangeNotification:changedFields:instance: when no instances are loaded?

marcoarment commented 10 years ago

Thanks. Simple oversight when changing that into a static method: locks aren't class-specific, so they should all just be called on self and assumed to be FCModel's top-level lock.