[libgepub] widget: Fix warning at run-time



commit fc0df7825e15b741ef35eeed4eba2538631c758e
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 15 18:37:54 2018 +0100

    widget: Fix warning at run-time
    
    There's nothing to reload if we don't have a doc already loaded.
    
    ** (org.gnome.Books:19113): CRITICAL **: gepub_doc_get_current_with_epub_uris: assertion 'GEPUB_IS_DOC 
(doc)' failed
    
     #0  _g_log_abort (breakpoint=breakpoint@entry=1) at 
/home/hadess/Projects/jhbuild/glib/glib/gmessages.c:583
     #1  0x00007ffff51b6236 in g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_CRITICAL, format=<optimized 
out>, args=args@entry=0x7fffffff2068) at /home/hadess/Projects/jhbuild/glib/glib/gmessages.c:1391
     #2  0x00007ffff51b6382 in g_log (log_domain=log_domain@entry=0x0, 
log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff51ffffb "%s: assertion '%s' 
failed")
         at /home/hadess/Projects/jhbuild/glib/glib/gmessages.c:1432
     #3  0x00007ffff51b6989 in g_return_if_fail_warning (log_domain=log_domain@entry=0x0, 
pretty_function=pretty_function@entry=0x7fffd1b72740 <__func__.30500> "gepub_doc_get_current_with_epub_uris",
         expression=expression@entry=0x7fffd1b724a1 "GEPUB_IS_DOC (doc)") at 
/home/hadess/Projects/jhbuild/glib/glib/gmessages.c:2755
     #4  0x00007fffd1b706b0 in gepub_doc_get_current_with_epub_uris (doc=0x0) at 
libgepub/libgepub/gepub-doc.c:541
     #5  0x00007fffd1b7126f in reload_current_chapter (widget=0x5555562341f0) at 
libgepub/libgepub/gepub-widget.c:446

 libgepub/gepub-widget.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/libgepub/gepub-widget.c b/libgepub/gepub-widget.c
index 222fceb..44bd173 100644
--- a/libgepub/gepub-widget.c
+++ b/libgepub/gepub-widget.c
@@ -443,6 +443,9 @@ reload_current_chapter (GepubWidget *widget)
     widget->chapter_pos = 0;
     widget->length = 0;
 
+    if (widget->doc == NULL)
+        return;
+
     current = gepub_doc_get_current_with_epub_uris (widget->doc);
     webkit_web_view_load_bytes (WEBKIT_WEB_VIEW (widget),
                                 current,


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