You have to isolate why the background is black. You can see it is not black in my code so there is nothing wrong with the cache in general. As for your bounding rect - see that when your item has no children its bounding rect will be invalid. If you create the cache at that time and not pass the amount of memory you want allocated for the item's cache, it will allocate as much memory as needed to fit your bounding rect. Which in your case is... 0. This is likely to lead to problems although I'd expect everything to be black, not just the background.
I suggest you start from scratch (or with my code) and build upon it until you encounter a situation where cache fails. It might take shorter than wild bug chasing.
Bookmarks