[webkit-gtk] How to load and process different URI with webkitgtk using multi-thread

Albert 1804296947 at qq.com
Fri Jul 13 02:53:36 PDT 2012


Dear Gavin,
  Thank your for your suggestion. 
  But I still have questions:
  1. How can I call webkit_web_view_load_uri(web_view, uri) after calling
gtk_main () in the same thread? (gtk_main() doesn't return after calling)
  2. How can I process the "resource-load-finished" callback on the same
thread?
    ( In my one thread program, I call g_signal_connect(webView,
"resource-load-finished", ...) before calling gtk_main() 
     a.  In "resource-load-finished" callback function, when calling
webkit_web_view_stop_loading(webView), the app core dumped at gtk_main ()
   or b.  In "resource-load-finished" callback function, when calling
webkit_web_view_load_uri(web_view, another_uri), the app also core dumped at
gtk_main () )


Thank you,
Albert
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------------------------------------------------


>You can't do that sort of thing.  UI components (including the public API
of
>WebKit) tend to be thread-bound, so must always be accessed from the same
>thread they were created on.

>For the above scenario (which is a bit weird -- usually the main thread is
>the one running the GUI), you would need to call load_uri from ThreadA, and
>also process the load-finished callback on that thread too.  You can then
>extract whatever data you need and use some thread-safe mechanism to pass
>that across to your non-UI thread.  (For worker thread -> UI thread
>notifications you can use Glib::Dispatcher; I'm not sure if that works the
>other way around though.)





More information about the webkit-gtk mailing list