[libgepub/wip/hadess/cant-register-more-than-once] widget: Fix ePubs not rendering after the first one




commit ea0799c086b0e9b60223bd773f89d857fbf76ab5
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 30 20:10:11 2021 +0200

    widget: Fix ePubs not rendering after the first one
    
    Fix critical error in gnome-books:
    Cannot register URI scheme epub more than once
    
    Create a new WebKitWebContext for each widget, so we don't run into the
    error above.

 libgepub/gepub-widget.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/libgepub/gepub-widget.c b/libgepub/gepub-widget.c
index 9615227..d2559b9 100644
--- a/libgepub/gepub-widget.c
+++ b/libgepub/gepub-widget.c
@@ -388,6 +388,25 @@ gepub_widget_init (GepubWidget *widget)
     widget->line_height = 0;
 }
 
+static GObject *
+gepub_widget_constructor (GType                  gtype,
+                          guint                  n_properties,
+                          GObjectConstructParam *properties)
+{
+  GObject *object;
+  GObjectClass *parent_class;
+
+  parent_class = G_OBJECT_CLASS (gepub_widget_parent_class);
+  object = parent_class->constructor (gtype, n_properties, properties);
+
+  g_object_set (object,
+                "web-context", g_object_new (WEBKIT_TYPE_WEB_CONTEXT, NULL),
+                NULL);
+
+  return object;
+}
+
+
 static void
 gepub_widget_constructed (GObject *object)
 {
@@ -407,6 +426,7 @@ gepub_widget_class_init (GepubWidgetClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+    object_class->constructor = gepub_widget_constructor;
     object_class->constructed = gepub_widget_constructed;
     object_class->finalize = gepub_widget_finalize;
     object_class->set_property = gepub_widget_set_property;


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