context.parentStack == nil #253

Closed
opened 2025-12-29 15:27:40 +01:00 by adam · 8 comments
Owner

Originally created by @dufflink on GitHub (Jan 15, 2019).

Hello! I did as you advised #281 but the problem remained the same.

2019-01-10 11 46 15 The initDB function is called every time I log in as a user.

The error occurs only when I log out from the account of one user and immediately try to log in to another user.

2019-01-10 11 52 02
Originally created by @dufflink on GitHub (Jan 15, 2019). Hello! I did as you advised [#281](https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-444428619) but the problem remained the same. <img width="1072" alt="2019-01-10 11 46 15" src="https://user-images.githubusercontent.com/29461219/51168294-a871c700-18ca-11e9-8dde-c780c66f09b9.png"> The initDB function is called every time I log in as a user. The error occurs only when I log out from the account of one user and immediately try to log in to another user. <img width="462" alt="2019-01-10 11 52 02" src="https://user-images.githubusercontent.com/29461219/51168326-bde6f100-18ca-11e9-9029-6d0e4ae8a183.png">
adam closed this issue 2025-12-29 15:27:40 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Jan 16, 2019):

You are trying to add your sqlite store to a new DataStack when it is still being used by the old DataStack (CoreStore.defaultStack still holds the old stack)

I recommend that you set your CoreStore.defaultStack to a new DataStack, give the old stack time to release itself, then add the sqlite store to the new stack.

@JohnEstropia commented on GitHub (Jan 16, 2019): You are trying to add your sqlite store to a new DataStack when it is still being used by the old DataStack (CoreStore.defaultStack still holds the old stack) I recommend that you set your CoreStore.defaultStack to a new DataStack, give the old stack time to release itself, then add the sqlite store to the new stack.
Author
Owner

@dufflink commented on GitHub (Jan 16, 2019):

How can i give the old stack time to release itself?

@dufflink commented on GitHub (Jan 16, 2019): How can i give the old stack time to release itself?
Author
Owner

@dufflink commented on GitHub (Jan 17, 2019):

It works for me:
I added a nil check for dataStack

2019-01-17 11 47 32
@dufflink commented on GitHub (Jan 17, 2019): It works for me: I added a nil check for dataStack <img width="808" alt="2019-01-17 11 47 32" src="https://user-images.githubusercontent.com/29461219/51300476-d3d0ef00-1a4d-11e9-8ff9-291ec198b494.png">
Author
Owner

@dufflink commented on GitHub (Jan 18, 2019):

How can I use two different SQLite stores in one data stack? Now, I still have data from another user (Message, Chats)

@dufflink commented on GitHub (Jan 18, 2019): How can I use two different SQLite stores in one data stack? Now, I still have data from another user (Message, Chats)
Author
Owner

@JohnEstropia commented on GitHub (Jan 21, 2019):

You will have to release the DataStack used by your old account. Your old code was fine: https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-442388594

Your issue in #281 is not the database setup code. You have other processes in your app that still use the old DataStack. They may be View Controllers, or something else. That's what you should focus debugging, those objects need to be deallocated before you call initDb() again with the new account.

I'm closing this issue in a while as this is an application-side issue. I assure you that switching DataStacks work, the CoreStore demo app does it (see: 40f458a09c/CoreStoreDemo/CoreStoreDemo/MIgrations%20Demo/MigrationsDemoViewController.swift (L243))

@JohnEstropia commented on GitHub (Jan 21, 2019): You will have to release the `DataStack` used by your old account. Your old code was fine: https://github.com/JohnEstropia/CoreStore/issues/281#issuecomment-442388594 Your issue in #281 is not the database setup code. You have other processes in your app that still use the old DataStack. They may be View Controllers, or something else. That's what you should focus debugging, those objects need to be deallocated before you call `initDb()` again with the new account. I'm closing this issue in a while as this is an application-side issue. I assure you that switching DataStacks work, the CoreStore demo app does it (see: https://github.com/JohnEstropia/CoreStore/blob/40f458a09c0177d15ceab1561acaede2799c4f2d/CoreStoreDemo/CoreStoreDemo/MIgrations%20Demo/MigrationsDemoViewController.swift#L243)
Author
Owner

@dufflink commented on GitHub (Jan 21, 2019):

Could you share your login in Telegram? Or any other social network

@dufflink commented on GitHub (Jan 21, 2019): Could you share your login in Telegram? Or any other social network
Author
Owner

@JohnEstropia commented on GitHub (Jan 21, 2019):

@MaxPaymon I don't have a Telegram account, but CoreStore has a Slack group: http://swift-corestore-slack.herokuapp.com/

I'd be happy to help you where I can. I do suggest you refer to the MigrationsDemoViewController.swift in the demo app first, it shows a ViewController that changes DataStack and ListMonitor instances each time you tap on a different model version.

@JohnEstropia commented on GitHub (Jan 21, 2019): @MaxPaymon I don't have a Telegram account, but CoreStore has a Slack group: http://swift-corestore-slack.herokuapp.com/ I'd be happy to help you where I can. I do suggest you refer to the `MigrationsDemoViewController.swift` in the demo app first, it shows a ViewController that changes `DataStack` and `ListMonitor` instances each time you tap on a different model version.
Author
Owner

@dufflink commented on GitHub (Jan 21, 2019):

Ok, thanks!

@dufflink commented on GitHub (Jan 21, 2019): Ok, thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#253