[glom] More dealing with cppcheck errors.



commit 7d5ca968034ce521bd1be7ab6102f1eddf0a15b0
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Dec 16 16:21:40 2010 +0100

    More dealing with cppcheck errors.
    
    * glom/libglom/data_structure/layout/layoutitem.cc: operator=(): Check for
    src=this.
    * glom/base_db.cc:
    * glom/frame_glom.cc:
    * glom/frame_glom.h:
    * glom/libglom/connectionpool_backends/postgres_central.cc:
    * glom/libglom/data_structure/foundset.cc:
    * glom/libglom/data_structure/foundset.h:
    * glom/libglom/document/bakery/document_xml.cc:
    * glom/libglom/document/bakery/document_xml.h:
    * glom/libglom/document/document.cc:
    * glom/utility_widgets/adddel/adddel.cc:
    * tests/import/test_parsing.cc:
    * tests/import/test_signals.cc: Removed unused methods and unused variables.

 ChangeLog                                          |   19 +++++++
 glom/base_db.cc                                    |    2 -
 glom/frame_glom.cc                                 |   52 --------------------
 glom/frame_glom.h                                  |    1 -
 .../connectionpool_backends/postgres_central.cc    |    2 +-
 glom/libglom/data_structure/foundset.cc            |    6 --
 glom/libglom/data_structure/foundset.h             |    4 --
 glom/libglom/data_structure/layout/layoutitem.cc   |    3 +
 glom/libglom/document/bakery/document_xml.cc       |    6 --
 glom/libglom/document/bakery/document_xml.h        |    6 --
 glom/libglom/document/document.cc                  |    2 +-
 glom/utility_widgets/adddel/adddel.cc              |    7 +--
 tests/import/test_parsing.cc                       |    6 ++-
 tests/import/test_signals.cc                       |    2 +
 14 files changed, 33 insertions(+), 85 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff4d03f..2fd6e0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2010-12-16  Murray Cumming  <murrayc murrayc com>
 
+	More dealing with cppcheck errors. 
+
+	* glom/libglom/data_structure/layout/layoutitem.cc: operator=(): Check for 
+	src=this.
+	* glom/base_db.cc:
+	* glom/frame_glom.cc:
+	* glom/frame_glom.h:
+	* glom/libglom/connectionpool_backends/postgres_central.cc:
+	* glom/libglom/data_structure/foundset.cc:
+	* glom/libglom/data_structure/foundset.h:
+	* glom/libglom/document/bakery/document_xml.cc:
+	* glom/libglom/document/bakery/document_xml.h:
+	* glom/libglom/document/document.cc:
+	* glom/utility_widgets/adddel/adddel.cc:
+	* tests/import/test_parsing.cc:
+	* tests/import/test_signals.cc: Removed unused methods and unused variables.
+
+2010-12-16  Murray Cumming  <murrayc murrayc com>
+
 	Remove unused methods.
 	
 	* glom/libglom/data_structure/glomconversions.cc:
diff --git a/glom/base_db.cc b/glom/base_db.cc
index 924ac1a..fde20f9 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -300,7 +300,6 @@ namespace
   sharedptr<Field> check_field_change_constraints(const sharedptr<const Field>& field_old, const sharedptr<const Field>& field)
   {
     sharedptr<Field> result = glom_sharedptr_clone(field);
-    bool primary_key_was_set = false;
     bool primary_key_was_unset = false;
     if(field_old->get_primary_key() != field->get_primary_key())
     {
@@ -310,7 +309,6 @@ namespace
       if(field->get_primary_key())
       {
         result->set_unique_key();
-        primary_key_was_set = true;
       }
       else
       {
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 5d80be5..4f92bc1 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -715,58 +715,6 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
   }
 }
 
-void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
-{
-  type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
-
-  if(fieldsSequence.empty())
-  {
-    std::cerr << G_STRFUNC << ": No fields in sequence." << std::endl;
-    return;
-  }
-
-  Glib::RefPtr<Gnome::Gda::SqlBuilder> query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
-
-  //TODO: Lock the database (prevent changes) during export.
-  Glib::RefPtr<const Gnome::Gda::DataModel> result = DbUtils::query_execute_select(query);
-
-  guint rows_count = 0;
-  if(result)
-    rows_count = result->get_n_rows();
-
-  if(rows_count)
-  {
-    const guint columns_count = result->get_n_columns();
-
-    for(guint row_index = 0; row_index < rows_count; ++row_index)
-    {
-        std::string row_string;
-
-        for(guint col_index = 0; col_index < columns_count; ++col_index)
-        {
-          const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
-
-          sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
-          //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
-          //{
-            if(!row_string.empty())
-              row_string += ',';
-
-            //Output data in canonical SQL format, ignoring the user's locale, and ignoring the layout formatting:
-            row_string += layout_item->get_full_field_details()->to_file_format(value);
-
-            //if(layout_item->m_field.get_glom_type() == Field::TYPE_IMAGE) //This is too much data.
-            //{
-             //std::cout << "  field name=" << layout_item->get_name() << ", value=" << layout_item->m_field.sql(value) << std::endl;
-            //}
-        }
-
-        //std::cout << " row_string=" << row_string << std::endl;
-        the_string += (row_string += "\n");
-    }
-  }
-}
-
 void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
 {
   type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
diff --git a/glom/frame_glom.h b/glom/frame_glom.h
index 77c83eb..c347779 100644
--- a/glom/frame_glom.h
+++ b/glom/frame_glom.h
@@ -170,7 +170,6 @@ public:
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
   void export_data_to_vector(Document::type_example_rows& the_vector, const FoundSet& found_set, const Document::type_list_layout_groups& sequence);
-  void export_data_to_string(Glib::ustring& the_string, const FoundSet& found_set, const Document::type_list_layout_groups& sequence);
   void export_data_to_stream(std::ostream& the_stream, const FoundSet& found_set, const Document::type_list_layout_groups& sequence);
 
   /** Show the table again. For instance, if the document has changed, or we want to display it differently.
diff --git a/glom/libglom/connectionpool_backends/postgres_central.cc b/glom/libglom/connectionpool_backends/postgres_central.cc
index 62eb78e..e3f32ed 100644
--- a/glom/libglom/connectionpool_backends/postgres_central.cc
+++ b/glom/libglom/connectionpool_backends/postgres_central.cc
@@ -103,7 +103,7 @@ Glib::RefPtr<Gnome::Gda::Connection> PostgresCentralHosted::connect(const Glib::
   catch(const ExceptionConnection& ex)
   {
     // Remember port if only the database was missing
-    bool connection_possible = false;
+    connection_possible = false;
     if(ex.get_failure_type() == ExceptionConnection::FAILURE_NO_DATABASE)
     {
       connection_possible = true;
diff --git a/glom/libglom/data_structure/foundset.cc b/glom/libglom/data_structure/foundset.cc
index 985a845..e2c01f1 100644
--- a/glom/libglom/data_structure/foundset.cc
+++ b/glom/libglom/data_structure/foundset.cc
@@ -53,10 +53,4 @@ bool FoundSet::operator==(const FoundSet& src) const
       && (m_sort_clause == src.m_sort_clause);
 }
 
-bool FoundSet::has_no_criteria() const
-{
-  return m_where_clause.empty() &&
-    m_sort_clause.empty();
-}
-
 } //namespace Glom
diff --git a/glom/libglom/data_structure/foundset.h b/glom/libglom/data_structure/foundset.h
index 5eeacaa..2eb610d 100644
--- a/glom/libglom/data_structure/foundset.h
+++ b/glom/libglom/data_structure/foundset.h
@@ -43,10 +43,6 @@ public:
 
   bool operator==(const FoundSet& src) const;
 
-  /** Whether this specifies any where clause or sort order.
-   */
-  bool has_no_criteria() const;
-
   Glib::ustring m_table_name;
   sharedptr<const Relationship> m_extra_join; // Only used for doubly-related related records (portals), in which case the WHERE clause is also slightly different.
   Gnome::Gda::SqlExpr m_where_clause;
diff --git a/glom/libglom/data_structure/layout/layoutitem.cc b/glom/libglom/data_structure/layout/layoutitem.cc
index 436af3b..f46928b 100644
--- a/glom/libglom/data_structure/layout/layoutitem.cc
+++ b/glom/libglom/data_structure/layout/layoutitem.cc
@@ -86,6 +86,9 @@ LayoutItem::~LayoutItem()
 
 LayoutItem& LayoutItem::operator=(const LayoutItem& src)
 {
+  if(this == &src)
+    return *this;
+
   TranslatableItem::operator=(src);
 
   m_editable = src.m_editable;
diff --git a/glom/libglom/document/bakery/document_xml.cc b/glom/libglom/document/bakery/document_xml.cc
index 96ba688..a01c0e8 100644
--- a/glom/libglom/document/bakery/document_xml.cc
+++ b/glom/libglom/document/bakery/document_xml.cc
@@ -230,12 +230,6 @@ xmlpp::Element* Document_XML::get_node_document()
   return nodeRoot;
 }
 
-void Document_XML::set_write_formatted(bool formatted)
-{
-  m_write_formatted = formatted;
-}
-
-
 void Document_XML::add_indenting_white_space_to_node(xmlpp::Node* node, const Glib::ustring& start_indent)
 {
   if(!node)
diff --git a/glom/libglom/document/bakery/document_xml.h b/glom/libglom/document/bakery/document_xml.h
index 612d0b2..0dda1cb 100644
--- a/glom/libglom/document/bakery/document_xml.h
+++ b/glom/libglom/document/bakery/document_xml.h
@@ -52,12 +52,6 @@ public:
   
   Glib::ustring get_dtd_root_node_name() const;
 
-  /** Whether to add extra whitespace when writing the XML to disk.
-   * Do not use this if whitespace is significant in your XML format.
-   * See also add_indenting_white_space().
-   */
-  void set_write_formatted(bool formatted = true);
-
   /** Put each node on its own line and add white space for indenting,
    * even if there are child text nodes.
    * set_write_formatted() does not cause nodes to be indented if there are child text nodes,
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 34c2bbd..78b3c65 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -317,7 +317,7 @@ bool Document::get_network_shared() const
   else if(hosting_mode == HOSTING_MODE_SQLITE)
     shared = false; //sqlite does not allow network sharing.
 
-  return m_network_shared;
+  return shared;
 }
 
 std::string Document::get_connection_self_hosted_directory_uri() const
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index 09e42b9..ec2d14c 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -630,7 +630,6 @@ void AddDel::construct_specified_columns()
       const Glib::ustring column_name = m_ColumnTypes[model_column_index].m_name;
       const Glib::ustring column_id = m_ColumnTypes[model_column_index].m_id;
 
-      int cols_count = 0;
       switch(m_ColumnTypes[model_column_index].m_style)
       {
         case(AddDelColumnInfo::STYLE_Choices):
@@ -648,7 +647,7 @@ void AddDel::construct_specified_columns()
           // Append the View column.
           // We use a derived Gtk::TreeViewColumn so that we can store extra information in it.
           // This means that we must reimplement the code from the convenience template methods from gtkmm.
-          cols_count = treeview_append_column( Utils::string_escape_underscores(column_name), *pCellRenderer,  *pModelColumn, column_id);
+          treeview_append_column( Utils::string_escape_underscores(column_name), *pCellRenderer,  *pModelColumn, column_id);
 
           break;
         }
@@ -661,7 +660,7 @@ void AddDel::construct_specified_columns()
 
           Gtk::TreeModelColumn<bool>* pModelColumnDerived = static_cast< Gtk::TreeModelColumn<bool>* >(pModelColumn);
           if(pModelColumnDerived)
-            cols_count = treeview_append_column(Utils::string_escape_underscores(column_name), *pModelColumnDerived, column_id);
+            treeview_append_column(Utils::string_escape_underscores(column_name), *pModelColumnDerived, column_id);
 
           break;
         }
@@ -673,7 +672,7 @@ void AddDel::construct_specified_columns()
           //to use the correct specialization:
           Gtk::TreeModelColumn<Glib::ustring>* pModelColumnDerived = static_cast< Gtk::TreeModelColumn<Glib::ustring>* >(pModelColumn);
           if(pModelColumnDerived)
-            cols_count = treeview_append_column(Utils::string_escape_underscores(column_name), *pModelColumnDerived, column_id);
+            treeview_append_column(Utils::string_escape_underscores(column_name), *pModelColumnDerived, column_id);
 
           break;
         }
diff --git a/tests/import/test_parsing.cc b/tests/import/test_parsing.cc
index 0f541f7..0e12ea7 100644
--- a/tests/import/test_parsing.cc
+++ b/tests/import/test_parsing.cc
@@ -13,8 +13,8 @@ typedef std::vector<std::string> type_tokens;
 
 type_tokens& get_tokens_instance()
 {
-  static type_tokens type_tokens;
-  return type_tokens;
+  static type_tokens tokens;
+  return tokens;
 }
 
 
@@ -30,6 +30,7 @@ void on_line_scanned(const std::vector<Glib::ustring>& row, guint /*line_number*
   }
 }
 
+/*
 void print_tokens()
 {
   for(type_tokens::const_iterator iter = get_tokens_instance().begin();
@@ -41,6 +42,7 @@ void print_tokens()
 
   std::cout << std::endl;
 }
+*/
 
 // Check that a string (or regex) exists in the parsed tokens.
 bool check_tokens(const std::string& regex)
diff --git a/tests/import/test_signals.cc b/tests/import/test_signals.cc
index 046faf1..456da48 100644
--- a/tests/import/test_signals.cc
+++ b/tests/import/test_signals.cc
@@ -38,11 +38,13 @@ void reset_signal_counts()
   get_encoding_error_count_instance() = 0;
 }
 
+/*
 void print_signal_counts()
 {
   std::cout << "lines scanned: " << get_line_scanned_count_instance() << std::endl;
   std::cout << "encoding errors: " << get_encoding_error_count_instance() << std::endl;
 }
+*/
 
 void connect_signals(Glom::CsvParser& parser)
 {



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