hi;

On 16 June 2013 15:09, iri <i...@irizone.net> wrote:

> I develop an application which using GObject and specific derived objects
> (in GTK 2.4 or 3.x).
>
> A module receives a pointer. It should be a GObject or derived but i'm not
> sure (I'm not the sender).
> So, to avoid bug / corruption / crash, i would check the quality of this
> pointer : GObject or not ?
> How can i make this ?

you cannot pass a random pointer and expect it to be able to test it.

more importantly:

>     gint i = 10;
>     b = G_IS_OBJECT (i);        /* KO : crash */

you cannot pass a random variable that is not even a pointer and
expect it to work.

in general, though, there is no way for you to take a random pointer
containing random stuff and expect that it is going to be known to the
type system, to be a GTypeInstance, or to be a GObject.

you do need to so some side band validation yourself, and if anything
else fails, you have to accept the fact that this is C, and segfaults
can happen because you passed a pointer with random garbage to a
function that was expecting a pointer to valid data.

ciao,
 Emmanuele.

--
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to