[glom/glom-1-24] Fix some clang compiler and analyzer warnings.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-24] Fix some clang compiler and analyzer warnings.
- Date: Tue, 15 Oct 2013 11:19:36 +0000 (UTC)
commit 5a94a3201f980d10ab285be5a2f5ec8fe6bb2a3c
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Oct 14 13:56:51 2013 +0200
Fix some clang compiler and analyzer warnings.
These are mostly checks after getting widgets from glade files.
glom/appwindow.cc | 10 ++-
glom/filechooser_export.cc | 2 +
glom/frame_glom.cc | 99 ++++++++++++++++----
glom/libglom/document/document.cc | 13 ++-
glom/libglom/python_embed/py_glom_ui.cc | 2 +-
glom/mode_data/db_adddel/db_adddel.cc | 20 ++--
glom/mode_design/layout/dialog_choose_field.cc | 5 +-
.../layout/dialog_layout_list_related.cc | 41 ++++++--
.../layout/layout_item_dialogs/box_formatting.cc | 8 +-
.../layout_item_dialogs/dialog_field_layout.cc | 7 +-
.../layout/layout_item_dialogs/dialog_group_by.cc | 7 +-
glom/utility_widgets/layoutwidgetbase.cc | 7 ++
12 files changed, 166 insertions(+), 55 deletions(-)
---
diff --git a/glom/appwindow.cc b/glom/appwindow.cc
index d973f4a..58421d1 100644
--- a/glom/appwindow.cc
+++ b/glom/appwindow.cc
@@ -106,11 +106,13 @@ AppWindow::AppWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&
#ifndef G_OS_WIN32
//Install UI hooks for this:
ConnectionPool* connection_pool = ConnectionPool::get_instance();
- if(!connection_pool)
+ if(connection_pool)
+ {
connection_pool->set_avahi_publish_callbacks(
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_begin),
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_progress),
sigc::mem_fun(*this, &AppWindow::on_connection_avahi_done) );
+ }
#endif
#endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -740,6 +742,12 @@ void AppWindow::open_browsed_document(const EpcServiceInfo* server, const Glib::
Dialog_Connection* dialog_connection = 0;
//Load the Glade file and instantiate its widgets to get the dialog stuff:
Utils::get_glade_widget_derived_with_warning(dialog_connection);
+ if(!dialog_connection)
+ {
+ std::cerr << G_STRFUNC << ": dialog_connection is null." << std::endl;
+ return;
+ }
+
dialog_connection->set_transient_for(*this);
dialog_connection->set_connect_to_browsed();
dialog_connection->set_database_name(service_name);
diff --git a/glom/filechooser_export.cc b/glom/filechooser_export.cc
index 1e5003f..c1556ff 100644
--- a/glom/filechooser_export.cc
+++ b/glom/filechooser_export.cc
@@ -55,6 +55,8 @@ FileChooser_Export::FileChooser_Export()
//TODO: Use a generic layout dialog?
Dialog_Layout_Export* dialog = 0;
Utils::get_glade_widget_derived_with_warning(dialog);
+ if(!dialog)
+ return;
m_pDialogLayout = dialog;
//add_view(m_pDialogLayout); //Give it access to the document.
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index bf97262..8344416 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -131,7 +131,8 @@ Frame_Glom::Frame_Glom(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
PlaceHolder* placeholder_quickfind = 0;
builder->get_widget_derived("vbox_quickfind", placeholder_quickfind);
- placeholder_quickfind->add(*m_pBox_QuickFind);
+ if(placeholder_quickfind)
+ placeholder_quickfind->add(*m_pBox_QuickFind);
//Add the Records/Found widgets at the right of the notebook tabs:
m_Box_RecordsCount.pack_start(
@@ -430,8 +431,11 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
show_table_title();
//List the reports and print layouts in the menus:
- pApp->fill_menu_reports(table_name);
- pApp->fill_menu_print_layouts(table_name);
+ if(pApp)
+ {
+ pApp->fill_menu_reports(table_name);
+ pApp->fill_menu_print_layouts(table_name);
+ }
//show_all();
}
@@ -779,23 +783,31 @@ void Frame_Glom::on_menu_file_import()
Dialog_Import_CSV_Progress* progress_dialog = 0;
Glom::Utils::get_glade_widget_derived_with_warning(progress_dialog);
- add_view(progress_dialog);
+ int response = Gtk::RESPONSE_OK;
+ if(!progress_dialog)
+ {
+ std::cerr << G_STRFUNC << ": progress_dialog was null." << std::endl;
+ }
+ else
+ {
+ add_view(progress_dialog);
- progress_dialog->init_db_details(dialog->get_target_table_name());
- progress_dialog->import(*dialog);
- const int response = progress_dialog->run();
+ progress_dialog->init_db_details(dialog->get_target_table_name());
+ progress_dialog->import(*dialog);
+ response = progress_dialog->run(); //TODO: Check response?
- remove_view(progress_dialog);
- delete progress_dialog;
- progress_dialog = 0;
+ remove_view(progress_dialog);
+ delete progress_dialog;
+ progress_dialog = 0;
- // Force update from database so the newly added entries are shown
- show_table_refresh();
+ // Force update from database so the newly added entries are shown
+ show_table_refresh();
- // Re-show chooser dialog when an error occured or when the user
- // cancelled.
- if(response == Gtk::RESPONSE_OK)
- break;
+ // Re-show chooser dialog when an error occured or when the user
+ // cancelled.
+ if(response == Gtk::RESPONSE_OK)
+ break;
+ }
}
remove_view(dialog);
@@ -1623,6 +1635,12 @@ void Frame_Glom::do_menu_developer_relationships(Gtk::Window& parent, const Glib
if(!m_pDialog_Relationships)
{
Utils::get_glade_widget_derived_with_warning(m_pDialog_Relationships);
+ if(!m_pDialog_Relationships)
+ {
+ std::cerr << G_STRFUNC << ": m_pDialog_Relationships is null." << std::cerr;
+ return;
+ }
+
m_pDialog_Relationships->set_title("Relationships");
m_pDialog_Relationships->signal_hide().connect( sigc::mem_fun(*this,
&Frame_Glom::on_developer_dialog_hide));
add_view(m_pDialog_Relationships); //Also a composite view.
@@ -1687,11 +1705,23 @@ void Frame_Glom::on_menu_developer_reports()
if(!m_pBox_Reports)
{
Utils::get_glade_child_widget_derived_with_warning(m_pBox_Reports);
+ if(!m_pBox_Reports)
+ {
+ std::cerr << G_STRFUNC << ": m_pBox_Reports is null." << std::cerr;
+ return;
+ }
+
m_pDialog_Reports = new Window_BoxHolder(m_pBox_Reports);
m_pDialog_Reports->set_transient_for(*(get_app_window()));
m_pDialog_Reports->set_title(_("Reports"));
Utils::get_glade_widget_derived_with_warning(m_pDialogLayoutReport);
+ if(!m_pDialogLayoutReport)
+ {
+ std::cerr << G_STRFUNC << ": m_pDialogLayoutReport is null." << std::endl;
+ return;
+ }
+
add_view(m_pDialogLayoutReport);
m_pDialogLayoutReport->set_transient_for(*(get_app_window()));
m_pDialogLayoutReport->signal_hide().connect( sigc::mem_fun(*this,
&Frame_Glom::on_dialog_layout_report_hide) );
@@ -1717,6 +1747,12 @@ void Frame_Glom::on_menu_developer_print_layouts()
if(!m_pBox_PrintLayouts)
{
Utils::get_glade_child_widget_derived_with_warning(m_pBox_PrintLayouts);
+ if(!m_pBox_PrintLayouts)
+ {
+ std::cerr << G_STRFUNC << ": m_pBox_PrintLayouts is null." << std::endl;
+ return;
+ }
+
m_pDialog_PrintLayouts = new Window_BoxHolder(m_pBox_PrintLayouts);
m_pDialog_PrintLayouts->set_transient_for(*get_app_window());
@@ -1766,9 +1802,15 @@ void Frame_Glom::on_box_reports_selected(const Glib::ustring& report_name)
void Frame_Glom::on_box_print_layouts_selected(const Glib::ustring& print_layout_name)
{
//Create the dialog if necessary:
- if(!m_pDialogLayoutPrint)
+ if(m_pDialogLayoutPrint)
{
Utils::get_glade_widget_derived_with_warning(m_pDialogLayoutPrint);
+ if(!m_pDialogLayoutPrint)
+ {
+ std::cerr << G_STRFUNC << ": m_pDialogLayoutPrint is null" << std::endl;
+ return;
+ }
+
add_view(m_pDialogLayoutPrint);
m_pDialogLayoutPrint->signal_hide().connect( sigc::mem_fun(*this,
&Frame_Glom::on_dialog_layout_print_hide) );
}
@@ -1778,7 +1820,10 @@ void Frame_Glom::on_box_print_layouts_selected(const Glib::ustring& print_layout
sharedptr<PrintLayout> print_layout = get_document()->get_print_layout(m_table_name, print_layout_name);
if(print_layout)
{
- m_pDialogLayoutPrint->set_transient_for(*get_app_window());
+ Gtk::Window* app_window = get_app_window();
+ if(app_window)
+ m_pDialogLayoutPrint->set_transient_for(*app_window);
+
m_pDialogLayoutPrint->set_print_layout(m_table_name, print_layout);
m_pDialogLayoutPrint->show();
}
@@ -1919,6 +1964,12 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
if(!m_pDialogConnection)
{
Utils::get_glade_widget_derived_with_warning(m_pDialogConnection);
+ if(!m_pDialogConnection)
+ {
+ std::cerr << G_STRFUNC << ": m_pBox_Reports is null." << std::cerr;
+ return false;
+ }
+
add_view(m_pDialogConnection); //Also a composite view.
}
@@ -2198,6 +2249,12 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
m_pDialogConnection = 0;
Utils::get_glade_widget_derived_with_warning(m_pDialogConnection);
+ if(!m_pDialogConnection)
+ {
+ std::cerr << G_STRFUNC << ": m_pDialogConnection is null." << std::endl;
+ return false;
+ }
+
add_view(m_pDialogConnection); //Also a composite view.
m_pDialogConnection->load_from_document(); //Get good defaults.
@@ -2303,6 +2360,12 @@ bool Frame_Glom::create_database(const Glib::ustring& database_name, const Glib:
//Tell the user:
Gtk::Dialog* dialog = 0;
Utils::get_glade_widget_with_warning("glom_developer.glade", "dialog_error_create_database", dialog);
+ if(!dialog)
+ {
+ std::cerr << G_STRFUNC << ": dialog is null." << std::cerr;
+ return false;
+ }
+
dialog->set_transient_for(*pWindowApp);
Glom::Utils::dialog_run_with_help(dialog, "dialog_error_create_database");
delete dialog;
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 092bd43..e13e898 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -3539,12 +3539,15 @@ void Document::save_before_layout_group(xmlpp::Element* node, const sharedptr<co
}
}
- //Save formatting for any layout items that use it:
- sharedptr<const LayoutItem_WithFormatting> withformatting = sharedptr<const
LayoutItem_WithFormatting>::cast_dynamic(item);
- if(withformatting)
+ if(nodeItem)
{
- xmlpp::Element* elementFormat = nodeItem->add_child(GLOM_NODE_FORMAT);
- save_before_layout_item_formatting(elementFormat, withformatting);
+ //Save formatting for any layout items that use it:
+ sharedptr<const LayoutItem_WithFormatting> withformatting = sharedptr<const
LayoutItem_WithFormatting>::cast_dynamic(item);
+ if(withformatting)
+ {
+ xmlpp::Element* elementFormat = nodeItem->add_child(GLOM_NODE_FORMAT);
+ save_before_layout_item_formatting(elementFormat, withformatting);
+ }
}
}
diff --git a/glom/libglom/python_embed/py_glom_ui.cc b/glom/libglom/python_embed/py_glom_ui.cc
index 11e0197..e9d8437 100644
--- a/glom/libglom/python_embed/py_glom_ui.cc
+++ b/glom/libglom/python_embed/py_glom_ui.cc
@@ -41,7 +41,7 @@ PyGlomUI::~PyGlomUI()
void PyGlomUI::show_table_details(const std::string& table_name, const boost::python::object&
primary_key_value)
{
- if(!m_callbacks && m_callbacks->m_slot_show_table_details)
+ if(!m_callbacks || !(m_callbacks->m_slot_show_table_details))
return;
Gnome::Gda::Value gda_primary_key_value;
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index cb70fb6..f30d474 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -1997,17 +1997,17 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
}
pDerived->property_text() = text;
- }
- //Show a different color if the value is numeric, if that's specified:
- if(type == Field::TYPE_NUMERIC)
- {
- const Glib::ustring fg_color =
- field->get_formatting_used().get_text_format_color_foreground_to_use(value);
- if(!fg_color.empty())
- pDerived->property_foreground() = fg_color;
- else //TODO: Remove this when this GTK+ bug is fixed:
https://bugzilla.gnome.org/show_bug.cgi?id=667415
- g_object_set(pDerived->gobj(), "foreground", (const char*)0, (gpointer)0);
+ //Show a different color if the value is numeric, if that's specified:
+ if(type == Field::TYPE_NUMERIC)
+ {
+ const Glib::ustring fg_color =
+ field->get_formatting_used().get_text_format_color_foreground_to_use(value);
+ if(!fg_color.empty())
+ pDerived->property_foreground() = fg_color;
+ else //TODO: Remove this when this GTK+ bug is fixed:
https://bugzilla.gnome.org/show_bug.cgi?id=667415
+ g_object_set(pDerived->gobj(), "foreground", (const char*)0, (gpointer)0);
+ }
}
break;
diff --git a/glom/mode_design/layout/dialog_choose_field.cc b/glom/mode_design/layout/dialog_choose_field.cc
index 189a197..a49f72b 100644
--- a/glom/mode_design/layout/dialog_choose_field.cc
+++ b/glom/mode_design/layout/dialog_choose_field.cc
@@ -45,7 +45,10 @@ Dialog_ChooseField::Dialog_ChooseField(BaseObjectType* cobject, const Glib::RefP
builder->get_widget("button_select", m_button_select);
builder->get_widget_derived("combobox_relationship", m_combo_relationship);
- m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_ChooseField::on_combo_relationship_changed));
+ if(m_combo_relationship)
+ {
+ m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_ChooseField::on_combo_relationship_changed));
+ }
builder->get_widget("treeview_fields", m_treeview);
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc
b/glom/mode_design/layout/dialog_layout_list_related.cc
index fc5e83a..ce570c9 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -67,11 +67,16 @@ Dialog_Layout_List_Related::Dialog_Layout_List_Related(BaseObjectType* cobject,
sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
builder->get_widget_derived("combo_relationship_name", m_combo_relationship);
- m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_combo_relationship_changed));
+ if(m_combo_relationship)
+ {
+ m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_combo_relationship_changed));
+ }
builder->get_widget("checkbutton_show_child_relationships", m_checkbutton_show_child_relationships);
- m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_checkbutton_show_child_relationships));
-
+ if(m_checkbutton_show_child_relationships)
+ {
+ m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_checkbutton_show_child_relationships));
+ }
builder->get_widget("radiobutton_navigation_automatic", m_radio_navigation_automatic);
@@ -82,18 +87,32 @@ Dialog_Layout_List_Related::Dialog_Layout_List_Related(BaseObjectType* cobject,
builder->get_widget("radiobutton_navigation_specify", m_radio_navigation_specify);
builder->get_widget_derived("combobox_navigation_specify", m_combo_navigation_specify);
- make_sensitivity_depend_on_toggle_button(*m_radio_navigation_specify, *m_combo_navigation_specify);
- m_combo_navigation_specify->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_combo_navigation_specific_changed));
+ if(m_radio_navigation_specify && m_combo_navigation_specify)
+ {
+ make_sensitivity_depend_on_toggle_button(*m_radio_navigation_specify, *m_combo_navigation_specify);
+ m_combo_navigation_specify->signal_changed().connect(sigc::mem_fun(*this,
&Dialog_Layout_List_Related::on_combo_navigation_specific_changed));
+ }
builder->get_widget("spinbutton_row_line_width", m_spinbutton_row_line_width);
- m_spinbutton_row_line_width->signal_value_changed().connect(
- sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ if(m_spinbutton_row_line_width)
+ {
+ m_spinbutton_row_line_width->signal_value_changed().connect(
+ sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ }
+
builder->get_widget("spinbutton_column_line_width", m_spinbutton_column_line_width);
- m_spinbutton_column_line_width->signal_value_changed().connect(
- sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ if(m_spinbutton_column_line_width)
+ {
+ m_spinbutton_column_line_width->signal_value_changed().connect(
+ sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ }
+
builder->get_widget("colorbutton_line", m_colorbutton_line);
- m_colorbutton_line->signal_color_set().connect(
- sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ if(m_colorbutton_line)
+ {
+ m_colorbutton_line->signal_color_set().connect(
+ sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_spinbutton_changed));
+ }
m_modified = false;
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
index dc73568..105d290 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -159,17 +159,17 @@ Box_Formatting::Box_Formatting(BaseObjectType* cobject, const Glib::RefPtr<Gtk::
m_button_choices_sortby->signal_clicked().connect( sigc::mem_fun(*this,
&Box_Formatting::on_button_choices_sortby) );
//TODO: Delay this until it is used?
- if(!m_dialog_choices_extra_fields)
+ Utils::get_glade_widget_derived_with_warning(m_dialog_choices_extra_fields);
+ if(m_dialog_choices_extra_fields)
{
- Utils::get_glade_widget_derived_with_warning(m_dialog_choices_extra_fields);
add_view(m_dialog_choices_extra_fields); //Give it access to the document.
m_dialog_choices_extra_fields->set_title(_("Extra Fields"));
}
//TODO: Delay this until it is used?
- if(!m_dialog_choices_sortby)
+ Utils::get_glade_widget_derived_with_warning(m_dialog_choices_sortby);
+ if(m_dialog_choices_sortby)
{
- Utils::get_glade_widget_derived_with_warning(m_dialog_choices_sortby);
add_view(m_dialog_choices_sortby); //Give it access to the document.
m_dialog_choices_sortby->set_title(_("Sort Order"));
}
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
index af493f8..a874fbf 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
@@ -56,8 +56,11 @@ Dialog_FieldLayout::Dialog_FieldLayout(BaseObjectType* cobject, const Glib::RefP
//Get the formatting stuff:
Utils::get_glade_child_widget_derived_with_warning(m_box_formatting);
- m_box_formatting_placeholder->pack_start(*m_box_formatting);
- add_view(m_box_formatting);
+ if(m_box_formatting)
+ {
+ m_box_formatting_placeholder->pack_start(*m_box_formatting);
+ add_view(m_box_formatting);
+ }
m_radiobutton_custom_formatting->signal_toggled().connect(sigc::mem_fun(*this,
&Dialog_FieldLayout::on_radiobutton_custom_formatting));
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
index e894fe8..f05a120 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
@@ -157,8 +157,11 @@ void Dialog_GroupBy::on_button_secondary_fields()
if(!m_dialog_choose_secondary_fields)
{
Utils::get_glade_widget_derived_with_warning(m_dialog_choose_secondary_fields);
- add_view(m_dialog_choose_secondary_fields); //Give it access to the document.
- m_dialog_choose_secondary_fields->set_title(_("Group By - Secondary Fields"));
+ if(m_dialog_choose_secondary_fields)
+ {
+ add_view(m_dialog_choose_secondary_fields); //Give it access to the document.
+ m_dialog_choose_secondary_fields->set_title(_("Group By - Secondary Fields"));
+ }
}
if(m_dialog_choose_secondary_fields)
diff --git a/glom/utility_widgets/layoutwidgetbase.cc b/glom/utility_widgets/layoutwidgetbase.cc
index ab310a8..bb8a9a1 100644
--- a/glom/utility_widgets/layoutwidgetbase.cc
+++ b/glom/utility_widgets/layoutwidgetbase.cc
@@ -23,6 +23,7 @@
#include <glom/appwindow.h>
#include <glom/mode_data/datawidget/textview.h>
#include <glom/mode_data/datawidget/label.h>
+#include <iostream>
namespace Glom
{
@@ -103,6 +104,12 @@ void LayoutWidgetBase::apply_formatting(Gtk::Widget& widget, const sharedptr<con
widget_to_change = labelglom->get_label();
}
+ if(!widget_to_change)
+ {
+ std::cerr << G_STRFUNC << ": widget_to_change is null." << std::endl;
+ return;
+ }
+
if(!layout_item)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]