Ticket #3670: browse-crash-fix.patch

File browse-crash-fix.patch, 1.0 KB (added by benzea, 12 years ago)

Nasty workaround that could be done in the activity.

  • webactivity.py

    diff --git a/webactivity.py b/webactivity.py
    index d33913f..c4999ec 100644
    a b class WebActivity(activity.Activity): 
    155155        _logger.debug('Starting the web activity')
    156156
    157157        session = WebKit.get_default_session()
     158
     159        # Reference the object, so that unrefing it later won't destroy it
     160        # Yes, we are deliberately leaking it, because otherwise
     161        # it would be destroyed *after* the python interpreter is finalized.
     162        # And that would result in a crash. See also:
     163        #   https://bugzilla.gnome.org/show_bug.cgi?id=678046
     164        #   http://bugs.sugarlabs.org/ticket/3670
     165        import ctypes
     166        import ctypes.util
     167        glib = ctypes.CDLL(ctypes.util.find_library('gobject-2.0'))
     168        # Note: the hash() of a GObject is its position in memory.
     169        glib.g_object_ref(ctypes.c_void_p(hash(session)))
     170
    158171        session.set_property('accept-language-auto', True)
    159172
    160173        # By default, cookies are not stored persistently, we have to