[glom/glom-1-20] Field::set_field_info(): Avoid unnecessary checks (and warnings).



commit ebfa29c6bb07f128ccaba886e3bfaca535dfa207
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Nov 28 21:21:57 2011 +0100

    Field::set_field_info(): Avoid unnecessary checks (and warnings).
    
    * glom/libglom/data_structure/field.cc: If the type is not yet set,
    don't bother checking that everything else uses that type.
    This avoids a stderr warning about invalid types being used.

 ChangeLog                            |    8 ++++++++
 glom/libglom/data_structure/field.cc |   15 +++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 60bfb05..e820470 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-28  Murray Cumming  <murrayc murray com>
+
+	Field::set_field_info(): Avoid unnecessary checks (and warnings).
+
+	* glom/libglom/data_structure/field.cc: If the type is not yet set,
+	don't bother checking that everything else uses that type.
+	This avoids a stderr warning about invalid types being used.
+
 2011-11-28  Murray Cumming  <murrayc murrayc comb>
 
 	Field::set_field_info(): Slight code improvement.
diff --git a/glom/libglom/data_structure/field.cc b/glom/libglom/data_structure/field.cc
index 8c453e7..0db4ee6 100644
--- a/glom/libglom/data_structure/field.cc
+++ b/glom/libglom/data_structure/field.cc
@@ -148,14 +148,21 @@ void Field::set_field_info(const Glib::RefPtr<Gnome::Gda::Column>& fieldinfo)
 {
   m_field_info = fieldinfo;
 
+  const glom_field_type glom_type = get_glom_type();
+  const GType new_type = fieldinfo->get_g_type();
+  if( (glom_type == TYPE_INVALID) &&
+    (new_type == GDA_TYPE_NULL)) //GDA_TYPE_NULL is the default for GdaColumn.
+  {
+    //Don't bother with any of the following checks.
+    return;
+  }
+
   // Also take fallback types into account as fieldinfo might originate from
   // the database system directly.
-  GType new_type = fieldinfo->get_g_type();
-
   GType cur_type = G_TYPE_NONE;
-  if(get_glom_type() != TYPE_INVALID)
+  if(glom_type != TYPE_INVALID)
   {
-    cur_type = get_gda_type_for_glom_type(get_glom_type());
+    cur_type = get_gda_type_for_glom_type(glom_type);
 
     const FieldTypes* pFieldTypes = get_field_types();
 



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