[glom] ImageGlom: Put EvView in ScrolledWindow to avoid crash.



commit eb8c3ab047b86ca7de431c5d5b14f6ab4c257574
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Feb 25 09:04:51 2016 +0100

    ImageGlom: Put EvView in ScrolledWindow to avoid crash.
    
    Because recent versions of libevince-view have an assert that crashes
    the application:
    https://bugzilla.gnome.org/show_bug.cgi?id=761396#c12

 glom/utility_widgets/imageglom.cc |   17 +++++++++++++++--
 glom/utility_widgets/imageglom.h  |    2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index b69e793..15b8104 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -48,7 +48,8 @@ ImageGlom::type_vec_ustrings ImageGlom::m_evince_supported_mime_types;
 ImageGlom::type_vec_ustrings ImageGlom::m_gdkpixbuf_supported_mime_types;
 
 ImageGlom::ImageGlom()
-: m_ev_view(nullptr),
+: m_ev_scrolled_window(nullptr),
+  m_ev_view(nullptr),
   m_ev_document_model(nullptr)
 {
   init();
@@ -56,6 +57,7 @@ ImageGlom::ImageGlom()
 
 ImageGlom::ImageGlom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& /* builder */)
 : Gtk::EventBox(cobject),
+  m_ev_scrolled_window(nullptr),
   m_ev_view(nullptr),
   m_ev_document_model(nullptr)
 {
@@ -64,7 +66,9 @@ ImageGlom::ImageGlom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&
 
 void ImageGlom::init()
 {
+  //TODO: Don't instantiate this unnecessarily.
   m_ev_view = EV_VIEW(ev_view_new());
+
   //gtk_widget_add_events(GTK_WIDGET(m_ev_view), GDK_BUTTON_PRESS_MASK);
 
   //Connect the the EvView's button-press-event signal, 
@@ -348,7 +352,16 @@ void ImageGlom::show_image_data()
     m_image.hide();
     
     gtk_widget_show(GTK_WIDGET(m_ev_view));
-    gtk_container_add(GTK_CONTAINER(m_frame.gobj()), GTK_WIDGET(m_ev_view));
+
+    if (!m_ev_scrolled_window)
+    {
+      m_ev_scrolled_window = Gtk::manage(new Gtk::ScrolledWindow());
+      m_ev_scrolled_window->show();
+      gtk_container_add(GTK_CONTAINER(m_ev_scrolled_window->gobj()), GTK_WIDGET(m_ev_view));
+    }
+
+    m_frame.add(*m_ev_scrolled_window);
+
 
     // Try loading from data in memory:
     // TODO: Uncomment this if this API is added: https://bugzilla.gnome.org/show_bug.cgi?id=654832
diff --git a/glom/utility_widgets/imageglom.h b/glom/utility_widgets/imageglom.h
index d57a365..0a0bb9b 100644
--- a/glom/utility_widgets/imageglom.h
+++ b/glom/utility_widgets/imageglom.h
@@ -28,6 +28,7 @@
 #include "layoutwidgetfield.h"
 #include <gtkmm/frame.h>
 #include <gtkmm/builder.h>
+#include <gtkmm/scrolledwindow.h>
 #include <giomm/appinfo.h>
 #include <giomm/simpleactiongroup.h>
 #include <evince-view.h>
@@ -108,6 +109,7 @@ private:
   Gtk::Frame m_frame;
   
   //For anything supported by Evince:
+  Gtk::ScrolledWindow* m_ev_scrolled_window;
   EvView* m_ev_view;
   EvDocumentModel* m_ev_document_model;
   


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