[glom] Privs::get_database_users(): Check for an empty DataModel.



commit 2f6c0b23810f987f79cedc42596ca964eaa0eff8
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jun 21 19:57:17 2010 +0200

    Privs::get_database_users(): Check for an empty DataModel.
    
    	* glom/libglom/privs.cc: Check that the user (listed in the group) could
    	really be found.

 ChangeLog             |    7 +++++++
 glom/libglom/privs.cc |    6 +++++-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index baddf9b..7f8af96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-06-21  Murray Cumming  <murrayc murrayc com>
 
+	Privs::get_database_users(): Check for an empty DataModel.
+
+	* glom/libglom/privs.cc: Check that the user (listed in the group) could 
+	really be found. 
+
+2010-06-21  Murray Cumming  <murrayc murrayc com>
+
 	Use G_STRFUNC with std::cerr and std::cout.
 
 	* *.h/cc: Replace hard-coded copy/pastes of method names with 
diff --git a/glom/libglom/privs.cc b/glom/libglom/privs.cc
index 7af6b8c..108e470 100644
--- a/glom/libglom/privs.cc
+++ b/glom/libglom/privs.cc
@@ -156,11 +156,15 @@ Privs::type_vec_strings Privs::get_database_users(const Glib::ustring& group_nam
               builder->add_field_id("usesysid", "pg_user"),
               builder->add_expr(*iter)));
           Glib::RefPtr<Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(builder);
-          if(data_model)
+          if(data_model && data_model->get_n_rows() && data_model->get_n_columns())
           {
             const Gnome::Gda::Value value = data_model->get_value_at(0, 0);
             result.push_back(value.get_string());
           }
+          else
+          {
+            std::cerr << G_STRFUNC << ": user not found in pg_user table: " << *iter << std::endl;
+          }
         }
 
       }



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