[webkit-gtk] Unexpected behaviour of webkit_web_view_set_settings

Gavin Lambert gavinl at compacsort.com
Tue Apr 19 20:00:24 PDT 2011


Quoth Martin Robinson:
> > Also, regarding webkit_web_view_init, it does look like that would
> > create an initial settings object, but I cannot actually find anywhere
> > that this function gets called.  It's static, so it would have to be
> > somewhere within webkitwebview.cpp, but I can't see it.  It's certainly
> > not getting called from webkit_web_view_new (which seems the most
> > logical place), unless there's some weird macro magic going on.
> 
> GObject initialization should call it automatically.

Hmm.  Ok, I think I can see that in the code, but still, this gives me a SIGSEGV (because 'settings' is a null pointer):

  Glib::RefPtr<WebKit::WebSettings> settings = m_web.get_settings();
  settings->get_property("user-agent", /*out*/ m_defaultUserAgent);

(m_web is a member variable of type WebKit::WebView.)


Ah!  Ok, I found the problem.  m_web was a member variable of my main window class, which was a member variable of the application class, which led to it being created before WebKit::init() was called.  I've moved the WebKit::init() call so it gets called before the application class gets constructed, and now get_settings() is giving me a non-null settings object.

My apologies for the noise.




More information about the webkit-gtk mailing list