PDA

View Full Version : QSharedData - implicit sharing



gyre
28th October 2007, 16:39
Hi all!...I need an advise...as usual :)
I want to use QShareData...
I create my class "DataStorage" let's say...and it contains a QSharedDataPointer<data_type> to some data that I need to be referenced in different threads let's say.
So now...when I want the implicit sharing of referenced data make work...When I reference ...should I create only the references of QSharedDataPointer<data_type> or references of QSharedData class that contains this DataPointer to make the implicit sharing work ?
I mean when I send this data using signal...should I use reference to QSharedData inheriting class or just reference to QSharedDataPointer<data_type> of this class ?
Thanks a LOT! :)

marcel
28th October 2007, 16:50
QSharedData is meant to be used together with QSharedDataPointer.
See this example: http://doc.trolltech.com/4.3/qshareddatapointer.html#details.

If you want it to work you should always use the QSharedData subclass, not the shared data pointer directly.

gyre
28th October 2007, 17:49
I know...I have implemented my code as it is shown in example you passed me...
What I was asking is HOW CAN I USE NOW IMPLEMENTED CLASSES TO SEND A DATA OVER SIGNAL AND MAKE REFERENCE COUNT WORKING ...
SHOULD I USE INHERITING QSHAREDATA CLASS CONTAING QSHAREDDATAPOINTER OR CAN I JUST SEND REFERENCE TO THIS POINTER TO MAKE REFERENCE COUNT WORKING ?
I THINK IT IS PRETTY CLEAR WHAT I WAS ASKING....
tHANKS

marcel
28th October 2007, 18:05
Well, the usage is obvious from the documentation, so I can't see what you can't understand.

Across signals and slots you should pass instances of your equivalent of the Employee class.
Maybe you can post the code, if this doesn't help you.

gyre
28th October 2007, 19:09
Thanks :)
that's what I needed to hear ...