[glom/glom-1-18] ComoboEntry: Check for a null Entry.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-18] ComoboEntry: Check for a null Entry.
- Date: Fri, 18 Mar 2011 10:41:08 +0000 (UTC)
commit fe13f7180bb1e5dd92955ff88cec56a3546a2f71
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Mar 18 11:40:59 2011 +0100
ComoboEntry: Check for a null Entry.
* glom/mode_data/datawidget/comboentry.cc: Always check the result of
Gtk::ComboBox::get_entry() for null before dereferencing it, to prevent a
crash.
However, this probably shouldn't happen, so I might investigate more.
This fixes bug #645041 (Ben Konrath)
ChangeLog | 22 +++++++++---
glom/mode_data/datawidget/comboentry.cc | 55 +++++++++++++++++++++++++------
2 files changed, 61 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 882a97b..b76e7ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,24 @@
+2011-03-18 Murray Cumming <murrayc murrayc com>
+
+ ComoboEntry: Check for a null Entry.
+
+ * glom/mode_data/datawidget/comboentry.cc: Always check the result of
+ Gtk::ComboBox::get_entry() for null before dereferencing it, to prevent a
+ crash.
+ However, this probably shouldn't happen, so I might investigate more.
+ This fixes bug #645041 (Ben Konrath)
+
2011-03-14 Murray Cumming <murrayc murrayc com>
Do not crash if PyDateTime_IMPORT fails.
- * glom/libglom/init.[h|cc]: Added libglom_pydatetime_import() and
+ * glom/libglom/init.[h|cc]: Added libglom_pydatetime_import() and
libglom_pydatetime_imported(). Remove the g_assert() when it fails.
- * glom/libglom/python_embed/pygdavalue_conversions.cc: Use the new
+ * glom/libglom/python_embed/pygdavalue_conversions.cc: Use the new
utility function instead of repeating our reimplementation here.
-
+
There will now just be an error message on stderr. We must fix this properly
- but in the meantime it is better than requiring the use of a separate glom
+ but in the meantime it is better than requiring the use of a separate glom
branch just for OnlineGlom.
See https://bugzilla.gnome.org/show_bug.cgi?id=644702
@@ -23,9 +33,9 @@
Make glom-1.18 parallel-installable with glom-1.16
* configure.ac: Increase the ABI version.
- * glom/python_embed/python_module/py_glom_module.cc: Load the correct
+ * glom/python_embed/python_module/py_glom_module.cc: Load the correct
python version.
-
+
I forgot to do this before.
2011-03-14 Murray Cumming <murrayc murrayc com>
diff --git a/glom/mode_data/datawidget/comboentry.cc b/glom/mode_data/datawidget/comboentry.cc
index 804e865..95bfe3f 100644
--- a/glom/mode_data/datawidget/comboentry.cc
+++ b/glom/mode_data/datawidget/comboentry.cc
@@ -100,12 +100,20 @@ void ComboEntry::init()
#endif
//We use connect(slot, false) to connect before the default signal handler, because the default signal handler prevents _further_ handling.
+
+ Gtk::Entry* entry = get_entry();
+ if(!entry)
+ {
+ std::cerr << G_STRFUNC << ": get_entry() returned null." << std::endl;
+ } else
+ {
#ifndef GLOM_ENABLE_CLIENT_ONLY
- get_entry()->signal_button_press_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_button_press_event), false);
+ signal_button_press_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_button_press_event), false);
#endif // GLOM_ENABLE_CLIENT_ONLY
- get_entry()->signal_focus_out_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_focus_out_event), false);
- get_entry()->signal_activate().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_activate));
+ entry->signal_focus_out_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_focus_out_event), false);
+ entry->signal_activate().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_activate));
+ }
}
ComboEntry::~ComboEntry()
@@ -155,12 +163,26 @@ void ComboEntry::set_layout_item(const sharedptr<LayoutItem>& layout_item, const
alignment = layout_field->get_formatting_used_horizontal_alignment();
const float x_align = (alignment == FieldFormatting::HORIZONTAL_ALIGNMENT_LEFT ? 0.0 : 1.0);
- get_entry()->set_alignment(x_align);
+
+ Gtk::Entry* entry = get_entry();
+ if(!entry)
+ {
+ std::cerr << G_STRFUNC << ": get_entry() returned null." << std::endl;
+ }
+ else
+ entry->set_alignment(x_align);
}
void ComboEntry::check_for_change()
{
- if(!(get_entry()->get_editable()))
+ Gtk::Entry* entry = get_entry();
+ if(!entry)
+ {
+ std::cerr << G_STRFUNC << ": get_entry() returned null." << std::endl;
+ return;
+ }
+
+ if(!(entry->get_editable()))
{
//Don't allow editing via the menu either, if the Entry is non-editable.
@@ -173,17 +195,17 @@ void ComboEntry::check_for_change()
Frame_Glom::show_ok_dialog(_("Read-only field."), _("This field may not be edited here."), *top_level_window, Gtk::MESSAGE_INFO);
//Change the entry back to the old value:
- get_entry()->set_text(m_old_text);
+ entry->set_text(m_old_text);
}
- Glib::ustring new_text = get_entry()->get_text();
+ const Glib::ustring new_text = entry->get_text();
if(new_text != m_old_text)
{
//Validate the input:
bool success = false;
sharedptr<const LayoutItem_Field> layout_item = sharedptr<const LayoutItem_Field>::cast_dynamic(get_layout_item());
- Gnome::Gda::Value value = Conversions::parse_value(layout_item->get_glom_type(), get_entry()->get_text(), layout_item->get_formatting_used().m_numeric_format, success);
+ Gnome::Gda::Value value = Conversions::parse_value(layout_item->get_glom_type(), entry->get_text(), layout_item->get_formatting_used().m_numeric_format, success);
if(success)
{
@@ -275,15 +297,28 @@ void ComboEntry::set_text(const Glib::ustring& text)
#endif //GLOM_ENABLE_MAEMO
//Call base class:
- get_entry()->set_text(text);
+ Gtk::Entry* entry = get_entry();
+ if(!entry)
+ {
+ std::cerr << G_STRFUNC << ": get_entry() returned null." << std::endl;
+ }
+ else
+ entry->set_text(text);
}
Gnome::Gda::Value ComboEntry::get_value() const
{
bool success = false;
+ const Gtk::Entry* entry = get_entry();
+ if(!entry)
+ {
+ std::cerr << G_STRFUNC << ": get_entry() returned null." << std::endl;
+ return Gnome::Gda::Value();
+ }
+
sharedptr<const LayoutItem_Field> layout_item = sharedptr<const LayoutItem_Field>::cast_dynamic(get_layout_item());
- return Conversions::parse_value(layout_item->get_glom_type(), get_entry()->get_text(), layout_item->get_formatting_used().m_numeric_format, success);
+ return Conversions::parse_value(layout_item->get_glom_type(), entry->get_text(), layout_item->get_formatting_used().m_numeric_format, success);
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]