Sending pointers to another process using GVariant

175 views Asked by At

I am currently developing a simple browser using webkit2gtk. In webkit2gtk, all DOM related operations are done in separate process called WebProcess.

I have created a GTKWidget in UI Process. I need to pass GTKWidget structure to WebProcess. Can we use GVariant for it?

I have read GVariant apis. I am able to send string, integer and other basic types using GVariant. But can we send objects using GVariant?

1

There are 1 answers

0
Marcus Müller On BEST ANSWER

So, we have to distinguish between your title and your question.

First your title:

Sending pointers to another process

yes, you can do that (pointers are usually convertible to an integer type), but pointers are always specific to one's process memory – the receiver process doesn't have access to that, so the pointer shows into nothingness (you get a segmentation fault), or worse, to something else (your program runs with wrong data).

But can we send objects using GVariant?

Generally, no. You can't look inside objects, so they might contain pointers. See my comment above.

However, many objects in fact work without pointers, so the type information and the memory that belongs to an object is sufficient to "recreate" it on the receiver side, just by casting the received memory into the shape of the object you know it is. However, that is very object-specific.

You will probably like to read about serialization.