[glom] ImageGlom: Ignore warning about invalid GdaBinary GValue.



commit 7a061b69af4a9d86d8491f02cea3dea3f7a184ad
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Jul 20 10:47:45 2011 +0200

    ImageGlom: Ignore warning about invalid GdaBinary GValue.
    
    * glom/utility_widgets/imageglom.[h|cc]: Add and use get_binary() method,
    to avoid trying to get a GdaBinary from a null (type) Gnome::Gda::Value.

 ChangeLog                         |    7 +++++++
 glom/utility_widgets/imageglom.cc |   20 +++++++++++++++-----
 glom/utility_widgets/imageglom.h  |    2 ++
 3 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 82b88c3..69b07c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-07-20  Murray Cumming  <murrayc murrayc com>
+
+	ImageGlom: Ignore warning about invalid GdaBinary GValue.
+
+	* glom/utility_widgets/imageglom.[h|cc]: Add and use get_binary() method, 
+	to avoid trying to get a GdaBinary from a null (type) Gnome::Gda::Value.
+
 2011-07-19  Murray Cumming  <murrayc murrayc com>
 
 	ImageGlom: Add commented-out code to load PDFs from memory.
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index d528797..2216fec 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -222,9 +222,19 @@ void ImageGlom::on_ev_job_finished(EvJob* job)
 	ev_view_set_loading(m_ev_view, FALSE);
 }
 
+const GdaBinary* ImageGlom::get_binary() const
+{
+  const GdaBinary* gda_binary = 0;
+  if(m_original_data.get_value_type() == GDA_TYPE_BINARY)
+    gda_binary = gda_value_get_binary(m_original_data.gobj());
+  
+  return gda_binary;
+}
+
 Glib::ustring ImageGlom::get_mime_type() const
 {
-  const GdaBinary* gda_binary = gda_value_get_binary(m_original_data.gobj());
+  const GdaBinary* gda_binary = get_binary();
+
   if(!gda_binary)
     return Glib::ustring();
     
@@ -333,7 +343,7 @@ void ImageGlom::show_image_data()
     // Try loading from data in memory:
     // TODO: Uncomment this if this API is added: https://bugzilla.gnome.org/show_bug.cgi?id=654832
     /*
-    const GdaBinary* gda_binary = gda_value_get_binary(m_original_data.gobj());
+    const GdaBinary* gda_binary = get_binary();
     if(!gda_binary || !gda_binary->data || !gda_binary->binary_length)
     {
        std::cerr << G_STRFUNC << "Data was null or empty." << std::endl;
@@ -693,7 +703,7 @@ bool ImageGlom::save_file_sync(const Glib::ustring& uri)
   //because we don't want to offer feedback.
   //Ideally, EvView would just load from data anyway.
   
-  const GdaBinary* gda_binary = gda_value_get_binary(m_original_data.gobj());
+  const GdaBinary* gda_binary = get_binary();
   if(!gda_binary)
   {
     std::cerr << G_STRFUNC << ": GdaBinary is null" << std::endl;
@@ -734,7 +744,7 @@ bool ImageGlom::save_file(const Glib::ustring& uri)
   if(pApp)
     dialog_save->set_transient_for(*pApp);
 
-  const GdaBinary* gda_binary = gda_value_get_binary(m_original_data.gobj());
+  const GdaBinary* gda_binary = get_binary();
   if(!gda_binary)
     return false;
 
@@ -816,7 +826,7 @@ void ImageGlom::on_clipboard_get(Gtk::SelectionData& selection_data, guint /* in
   
   if(target == mime_type)
   {
-    const GdaBinary* gda_binary = gda_value_get_binary(m_original_data.gobj());
+    const GdaBinary* gda_binary = get_binary();
     if(!gda_binary)
       return;
     
diff --git a/glom/utility_widgets/imageglom.h b/glom/utility_widgets/imageglom.h
index 4b70d01..ee5b031 100644
--- a/glom/utility_widgets/imageglom.h
+++ b/glom/utility_widgets/imageglom.h
@@ -82,6 +82,8 @@ private:
   void setup_menu_usermode();
   void show_image_data();
   
+  const GdaBinary* get_binary() const;
+  
   //Get a pixbuf scaled down to the current size allocation:
   Glib::RefPtr<Gdk::Pixbuf> get_scaled_image();
   



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