Fix: Retain cycle (db->extension->connection->db). See #332.#335
Conversation
Solution: Provide connection externally Breaking existing API.
|
I ended up fixing this in a slightly different manner. There are technically 2 ways to fix the retain cycle:
The weak reference is arguably the cleaner way to go about it. Although I can easily see people create a new connection just to pass it to the ActionManager init method. And then not retain the connection afterwards. And then submit a bug report saying the ActionManager doesn't work... :) But I recently ran into another issue with the ActionManager: it was starting before I was ready for it to do so. That is, during app launch, there were components that weren't ready yet. And the YapActionItems were trying to use them. So I added suspend/resume methods to ActionManager, that operate using a 'suspendCount'. Long story short: I ended up implementing both techniques. So you can still pass a YDBConnection in the init method, but it's not required. And if YDBActionManager does manage its own connection (i.e. you passed a nil connection during init), you can manually stop the action manager (via suspend), and it will drop its internally managed connection. |
|
Sounds like a best of two worlds solution for me :) |
Solution: Provide connection externally
Breaking existing API.
See #332 for discussion.