Re: ChamplainMapSourceChain ref_sink in champlain_view_set_map_source

On Thu, Apr 22, 2010 at 04:38, Victor Godoy Poluceno
<victorpoluceno gmail com> wrote:
> Hi everyone,
> I'm porting the 'local-rendering.c' demo to python and I get the
> message below and some 'segfaults' when I set a
> 'ChamplainMapSourceChain' to the 'map-source' property in 'view':
> ** ( CRITICAL **:
> champlain_map_source_get_tile_size: assertion `CHAMPLAIN_IS_MAP_SOURCE
> (map_source)' failed
> After some investigation, I think that problem happens after the
> 'g_object_ref_sink(source)' in 'champlain_view_set_map_source', line
> 2476. So, I changed g_object_ref_sink to g_object_ref and my code
> works properly without any message.
> There are any reason to use g_object_ref_sink or why that happens? If
> someone can help me I will appreciate that. I'm using Ubuntu Lucid
> Beta 2.
> --
> Victor Godoy Poluceno
> _______________________________________________
> libchamplain-list mailing list
> libchamplain-list gnome org


the ref_sink() was introduced by


and I followed this style too when doing some changes to libchamplain.
What I guess happens in your case is that you call something like

foo = champlain_map_source_chain_new()
// add some map sources into it

What's wrong is the last line - because map sources inherit from
GInitiallyUnowned now, when the objects are created, they have a
"floating reference" and when g_object_ref_sink(foo) is called, it
only clears the floating reference flag but does not increase the
reference count so calling g_object_unref(foo) above destroys the
object and champlain_view contains pointer to an invalid object. See

for more info.

This is an easy to overlook change in 0.5 with nasty consequences so
it would be good if all the binding maintainers checked their code if
it does the right thing (and go through the headers to see which
classes inherit from GInitiallyUnowned now).

(I could see that something like that happened also when I clicked the
map in your python bindings branch - may be related.)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]