PDA

View Full Version : Struggling with value space



UnicycleBloke
23rd May 2008, 13:43
I'm using Qtopia 4.3.

Background:
Having read the documentation, it seems that my application should create a QValueSpaceObject for each item it wishes to publish, and that these should exist for the lifetime of the application. Each object is essentially a server.

I also understand that wherever I need to read, be notified of changes, *or even change* a value space item, I can use an instance of QValueSpaceItem. The lifetime can be whatever I need in the context. Each object is essentially a client.

The documentation says that QValueSpaceItem::setValue requests the server to change the value, which it may or may not do. I assume the relevant QValueSpaceObject instance is located by some sort of cleverness involving shared memory - no direct signal/slot connection is made.

Problem:
My problem is that the signal QValueSpaceObject::itemSetValue() does not seem to be fired when I call setValue() on a QValueSpaceItem object. The objects use the same value space path.

Is this broken? Perhaps I have misunderstood the documentation, but the examples in the code seem to be what I'd expect. I'd be grateful for any examples of how to correctly set up the two ends of this virtual connection. I'm a bit confused by what would happen if a I create a temporary QValueSpaceObject in an attempt to update the value.

Thanks.

jacek
24th May 2008, 16:03
Have you tried invoking the sync() method? QValueSpaceItem documentation doesn't say much about it, but it is being used in QValueSpaceObject examples.

UnicycleBloke
28th May 2008, 23:41
Have you tried invoking the sync() method? QValueSpaceItem documentation doesn't say much about it, but it is being used in QValueSpaceObject examples.

Thanks for replying. Yes, I had tried that. The application either terminated abruptly or hung, so I suspect I fell foul of the non-threadsafe-ness. I think QValueSpaceItem does not work as advertised.

jacek
29th May 2008, 00:26
so I suspect I fell foul of the non-threadsafe-ness.
You didn't mention that you use threads in your first post.

The docs say:
Note: The QValueSpaceItem class is not thread safe and may only be used from an application's main thread.
so if you are using it in a non-GUI thread, it has right to misbehave.