[glom] DbUtils: Handle -1 for DataModel columns/rows counts.



commit 0da456141fa5b8249a9ab9ccf9f2343a0e8a23ee
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Mar 29 14:31:41 2016 +0200

    DbUtils: Handle -1 for DataModel columns/rows counts.

 glom/libglom/db_utils.cc          |    8 ++++----
 glom/libglom/document/document.cc |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 1f66411..dbc667d 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -2469,9 +2469,9 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
 
   if(datamodel)
   {
-    const guint count = datamodel->get_n_rows();
-    const guint cols_count = datamodel->get_n_columns();
-    for(guint row = 0; row < count; ++row)
+    const auto count = datamodel->get_n_rows(); // -1 means unknown
+    const auto cols_count = datamodel->get_n_columns(); // -1 means unknown
+    for(int row = 0; row < count; ++row)
     {
 
       std::pair<Gnome::Gda::Value, type_list_values> itempair;
@@ -2480,7 +2480,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
       if(layout_choice_extra && (cols_count > 1))
       {
         type_list_values list_values;
-        for(guint i = 1; i < cols_count; ++i)
+        for(int i = 1; i < cols_count; ++i)
         {
           list_values.emplace_back(datamodel->get_value_at(i, row));
         }
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 8749655..bc37380 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -4820,7 +4820,7 @@ bool add_file_to_archive(archive* a, const std::string& parent_dir_path, const s
       else
       {
         // Add the data to the archive:
-        ssize_t check = archive_write_data(a, buffer, bytes_read);
+        const auto check = archive_write_data(a, buffer, bytes_read);
         if(check != bytes_read)
         {
           std::cerr << G_STRFUNC << ": archive_write_data() wrote an unexpected number of bytes. \n";


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