Results 1 to 2 of 2

Thread: How to correctly subclass classes that use implicit sharing

  1. #1
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to correctly subclass classes that use implicit sharing

    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?
    Last edited by Gh0str1d3r; 16th August 2010 at 10:12.

  2. #2
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to correctly subclass classes that use implicit sharing

    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.
    Last edited by Gh0str1d3r; 16th August 2010 at 10:13.

Similar Threads

  1. Implicit sharing vs. c++ refereces
    By IrYoKu in forum Qt Programming
    Replies: 12
    Last Post: 9th November 2011, 23:20
  2. Implicit sharing and pointers
    By Luc4 in forum Qt Programming
    Replies: 4
    Last Post: 16th June 2010, 10:31
  3. QVector::data() and implicit sharing
    By abernat in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2009, 18:34
  4. Question about implicit sharing
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2009, 17:03
  5. QSharedData - implicit sharing
    By gyre in forum Newbie
    Replies: 4
    Last Post: 28th October 2007, 19:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.