Clifton Labrum
Clifton Labrum

Reputation: 14148

iOS Dropbox Datastore Crash after App Resumes

I listen for when my app resumes working (the user comes back to the app) and I fire a sync when this happens:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
  NSLog(@"App resumed...");
  //Fire a sync
  [[PPDropbox shared] sync];
}

I've had a few crash reports that happen after this event and an attempt to sync that says:

Fatal Exception: DBException
DBException: SHUTDOWN: sqlite_util.cpp:208: SqliteConnectionBase has been closed {-[DBDatastore sync:]}

My sync method currently looks like this:

-(void)sync
{
  if(self.datastore){
    [self.datastore sync:nil];
  }
}

Is there some kind of check I should be doing when I sync to ensure the SQLite connection is still available?

Dropbox Datastore version 3.1.1, iOS 8.1

Upvotes: 1

Views: 80

Answers (2)

air_bob
air_bob

Reputation: 1337

I encounter this same problem in my application. My scenario is like this: I unlink the account and shutdown the datastore. Then I try to link dropbox one more time.

My singleton instance tries the sync in - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url method, then it crashes with the same error mentioned in the question.

My problem is the datastore has been shutdown when I try to sync(I set the datastore only when singleton was init).

So what I did was just set the datastore before calling that sync, for instance self.datastore = [[DBDatastoreManager sharedManager] openDefaultDatastore:nil];

Upvotes: 1

Mike Crawford
Mike Crawford

Reputation: 2278

I speculate that your problem is not really that you've lost your connection to SQLite, rather that there is some other problem that corrupts the memory that uses SQLLite.

How sophisticated are you at testing and debugging? Try doing stuff like enabling Guard Malloc, and use assert to validate the parameters to your methods (if you have a pointer is it permitted to be NULL?).

My article on assertions might help: assert() is the Documentation that Keeps on Testing

Upvotes: 0

Related Questions