[gtkmm] Gtk::ComboBox and Scale: Fix signals that return a gchar*
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::ComboBox and Scale: Fix signals that return a gchar*
- Date: Mon, 26 Jun 2017 14:20:55 +0000 (UTC)
commit 4ca7d30bc72107b74c88ffbd15784b3e510a90ee
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Jun 26 16:16:38 2017 +0200
Gtk::ComboBox and Scale: Fix signals that return a gchar*
ComboBox::signal_format_entry_text() and Scale::signal_format_value()
shall delete the returned character array after it has been copied to a
Glib::ustring, or else they leak memory. They shall also convert an empty
Glib::ustring to a null gchar*. Bug 783360
gtk/src/combobox.hg | 16 +++++++++++-----
gtk/src/scale.hg | 19 +++++++++----------
2 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/gtk/src/combobox.hg b/gtk/src/combobox.hg
index 113a284..7aa3342 100644
--- a/gtk/src/combobox.hg
+++ b/gtk/src/combobox.hg
@@ -209,11 +209,17 @@ public:
_WRAP_SIGNAL(void changed(), "changed")
-#m4 dnl// The ::format_value signal handler should return a newly allocated string.
-#m4 dnl// (which is obviously not a const gchar*)
-#m4 _CONVERSION(`Glib::ustring',`const gchar*',`(strlen($3.c_str()) ? g_strdup($3.c_str()) : 0)')
-#m4 _CONVERSION(`const gchar*',`const TreeModel::Path&',`TreeModel::Path($3)')
-#m4 _CONVERSION(`const TreeModel::Path&',`const gchar*',`($3).to_string().c_str()')
+#m4begin
+dnl// The ::format_entry_text signal handler should return a newly allocated string.
+dnl// (which is obviously not a const gchar*)
+dnl// Also, ensure that format_entry_text never returns an empty char[],
+dnl// because that could be caused by an intermediate empty ustring from an initial null char*.
+dnl// See bug http://bugzilla.gnome.org/show_bug.cgi?id=168747.
+ _CONVERSION(`Glib::ustring',`gchar*',`g_strdup(Glib::c_str_or_nullptr($3))')
+ _CONVERSION(`gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
+ _CONVERSION(`const gchar*',`const TreeModel::Path&',`TreeModel::Path($3)')
+ _CONVERSION(`const TreeModel::Path&',`const gchar*',`($3).to_string().c_str()')
+#m4end
_WRAP_SIGNAL(Glib::ustring format_entry_text(const TreeModel::Path& path), "format-entry-text")
//Key-binding signals:
diff --git a/gtk/src/scale.hg b/gtk/src/scale.hg
index bb09d31..266f2cf 100644
--- a/gtk/src/scale.hg
+++ b/gtk/src/scale.hg
@@ -95,17 +95,16 @@ public:
_WRAP_METHOD(void add_mark(double value, PositionType position, const Glib::ustring& markup),
gtk_scale_add_mark)
_WRAP_METHOD(void clear_marks(), gtk_scale_clear_marks)
-#m4 dnl// The ::format_value signal handler should return a newly allocated string.
-#m4 dnl// (which is obviously not a const gchar*)
-#m4 dnl// Also, ensure that format_value never returns an empty char[],
-#m4 dnl// because that could be caused by an intermediate empty ustring from an initial null char*,
-#m4 dnl//See bug http://bugzilla.gnome.org/show_bug.cgi?id=168747.
-#m4 _CONVERSION(`Glib::ustring',`gchar*',`(strlen($3.c_str()) ? g_strdup($3.c_str()) : nullptr)')
-
+#m4begin
+dnl// The ::format_value signal handler should return a newly allocated string.
+dnl// (which is obviously not a const gchar*)
+dnl// Also, ensure that format_value never returns an empty char[],
+dnl// because that could be caused by an intermediate empty ustring from an initial null char*.
+dnl// See bug http://bugzilla.gnome.org/show_bug.cgi?id=168747.
+ _CONVERSION(`Glib::ustring',`gchar*',`g_strdup(Glib::c_str_or_nullptr($3))')
+ _CONVERSION(`gchar*',`Glib::ustring',`Glib::convert_return_gchar_ptr_to_ustring($3)')
+#m4end
_WRAP_SIGNAL(Glib::ustring format_value(double value), "format_value")
- // TODO: When we can break ABI, this signal needs to be
- // Glib::ustring format_value(double value, bool& use_default_formatting),
- // where use_default_formatting specifies whether the return value will actually be a null char*.
/** Number of displayed decimal digits.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]