[webkit-gtk] Unexpected behaviour of webkit_web_view_set_settings

Gavin Lambert gavinl at compacsort.com
Mon Apr 18 22:41:11 PDT 2011


I had a bit of code which used Glib::RefPtr from glibmm to create a
WebSettings object, set some properties up, then use webkitmm's set_settings
(which internally uses webkit_web_view_set_settings) to use the new
settings.  This much was working properly.

But then I let this RefPtr fall out of scope (which of course unreferenced
the underlying settings object).  When I later called get_settings
(webkit_web_view_get_settings), I was expecting to get the same object back
again, since the web view should have maintained a reference to it.  Instead
I was given a SIGSEGV because the object was no longer valid -- ie. it had
been destroyed when the RefPtr went out of scope.

The docs for webkit_web_view_set_settings claim that they release the
reference to the old settings object and add a reference to the new settings
object, which would be the correct thing to do.  However the code doesn't
appear to actually do that, as far as I can tell (I'm still a bit new to
some of this stuff).


An additional (although less important) bit of oddness is that trying to use
webkit_web_view_set_settings(NULL) to discard the customised settings is
greeted by an error.  This seems inconsistent with
webkit_web_view_get_settings initially returning a NULL object -- either it
should be possible to assign NULL back to the settings, or they should never
be NULL to begin with.



More information about the webkit-gtk mailing list