Home > Net >  Is it possible to store, set or update a value inside an existing GVariant
Is it possible to store, set or update a value inside an existing GVariant

Time:05-21

I have a simple floating-point glib variant object whose value I need to update, but there doesn't seem to be any functions to actually do that.

The only way seems to be to create a new variant object and update all places that have references to this object. The problem is that it's practically hard to impossible to update the references, and it would be much easier to just set the value inside the already existing variant object.

Is it even possible?

CodePudding user response:

No, GVariant is immutable after construction by design. This makes it safe to use across multiple threads.

The only way to update the value of a GVariant is to create a new GVariant with the new value.

  • Related