PDA

View Full Version : How to correctly subclass classes that use implicit sharing



Gh0str1d3r
16th August 2010, 10:25
Hi,

I am just working on a library with some classes using inheritance. One of my parent classes uses implicit sharing through QSharedData. Now I want to subclass this class, having still access to the QSharedData of the parent and adding some data to it.

So my question is how this should be done. I tried to subclass the QSharedData of the parent which did not work, then I tried to implement a new QSharedData in the child, thus effectively having 2 of them, which again failed.

So is it at all possible to derive from classes that use implicit sharing? If yes, how? And if no, what would be the best way to have at least the nice flexibility in regard to binary compatibility?

Gh0str1d3r
16th August 2010, 10:42
I just figured out that the actual problem was that it is not possible to have certain objects (like QGraphicsItem) in a QSharedData object. So now both possibilities of subclassing compile, but there is a seg fault when addressing the QSharedPointer of the child.