[glibmm] Use the utility functions for creating strings.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Use the utility functions for creating strings.
- Date: Tue, 29 Mar 2011 08:45:29 +0000 (UTC)
commit 9ee8e6c39f15a0c7731ae475313f51128df322d4
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Mar 29 10:45:18 2011 +0200
Use the utility functions for creating strings.
* gio/src/dbuserrorutils.ccg:
* gio/src/dbusownname.ccg:
* gio/src/dbusutils.ccg:
* gio/src/dbuswatchname.ccg:
* glib/src/fileutils.ccg:
* glib/src/iochannel.ccg:
* glib/src/markup.ccg:
* glib/src/variant.ccg: Use convert_const_gchar_ptr_to_ustring() and
convert_const_gchar_ptr_to_stdstring(), simplifying code and sometimes
avoiding crashes with NULL const char*.
ChangeLog | 15 +++++++++++++++
gio/src/dbuserrorutils.ccg | 2 +-
gio/src/dbusownname.ccg | 6 +++---
gio/src/dbusutils.ccg | 2 +-
gio/src/dbuswatchname.ccg | 10 +++++-----
glib/src/fileutils.ccg | 2 +-
glib/src/iochannel.ccg | 2 +-
glib/src/markup.ccg | 2 +-
glib/src/variant.ccg | 4 ++--
9 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d592aa..a140c6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2011-03-29 Murray Cumming <murrayc murrayc com>
+ Use the utility functions for creating strings.
+
+ * gio/src/dbuserrorutils.ccg:
+ * gio/src/dbusownname.ccg:
+ * gio/src/dbusutils.ccg:
+ * gio/src/dbuswatchname.ccg:
+ * glib/src/fileutils.ccg:
+ * glib/src/iochannel.ccg:
+ * glib/src/markup.ccg:
+ * glib/src/variant.ccg: Use convert_const_gchar_ptr_to_ustring() and
+ convert_const_gchar_ptr_to_stdstring(), simplifying code and sometimes
+ avoiding crashes with NULL const char*.
+
+2011-03-29 Murray Cumming <murrayc murrayc com>
+
Variant<std::string>::get(): Correct my custom implementation.
* glib/src/variant.ccg: Really call g_variant_get_bytestring().
diff --git a/gio/src/dbuserrorutils.ccg b/gio/src/dbuserrorutils.ccg
index dcf0c2f..0744aaa 100644
--- a/gio/src/dbuserrorutils.ccg
+++ b/gio/src/dbuserrorutils.ccg
@@ -35,7 +35,7 @@ bool is_remote_error(const Glib::Error& error)
Glib::ustring get_remote_error(const Glib::Error& error)
{
- return Glib::ustring(g_dbus_error_get_remote_error(error.gobj()));
+ return Glib::convert_const_gchar_ptr_to_ustring(g_dbus_error_get_remote_error(error.gobj()));
}
bool strip_remote_error(Glib::Error& error)
diff --git a/gio/src/dbusownname.ccg b/gio/src/dbusownname.ccg
index 6e5bb22..bdadb28 100644
--- a/gio/src/dbusownname.ccg
+++ b/gio/src/dbusownname.ccg
@@ -41,7 +41,7 @@ static void Bus_Acquired_giomm_callback(GDBusConnection* connection,
try
{
- (*the_slot)(Glib::wrap(connection, true), Glib::ustring(name));
+ (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name));
}
catch(...)
{
@@ -57,7 +57,7 @@ static void Bus_Name_Acquired_giomm_callback(GDBusConnection* connection,
try
{
- (*the_slot)(Glib::wrap(connection, true), Glib::ustring(name));
+ (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name));
}
catch(...)
{
@@ -73,7 +73,7 @@ static void Bus_Name_Lost_giomm_callback(GDBusConnection* connection,
try
{
- (*the_slot)(Glib::wrap(connection, true), Glib::ustring(name));
+ (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name));
}
catch(...)
{
diff --git a/gio/src/dbusutils.ccg b/gio/src/dbusutils.ccg
index 2d1d48e..3967fce 100644
--- a/gio/src/dbusutils.ccg
+++ b/gio/src/dbusutils.ccg
@@ -27,7 +27,7 @@ namespace DBus
std::string generate_guid()
{
- return std::string(g_dbus_generate_guid());
+ return Glib::convert_const_gchar_ptr_to_stdstring(g_dbus_generate_guid());
}
bool is_guid(const std::string& string)
diff --git a/gio/src/dbuswatchname.ccg b/gio/src/dbuswatchname.ccg
index 972b6cc..7c36e61 100644
--- a/gio/src/dbuswatchname.ccg
+++ b/gio/src/dbuswatchname.ccg
@@ -40,8 +40,8 @@ static void Bus_Name_Appeared_giomm_callback(GDBusConnection* connection,
try
{
- (*the_slot)(Glib::wrap(connection, true), Glib::ustring(name),
- Glib::ustring(name_owner));
+ (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name),
+ Glib::convert_const_gchar_ptr_to_ustring(name_owner));
}
catch(...)
{
@@ -57,7 +57,7 @@ static void Bus_Name_Vanished_giomm_callback(GDBusConnection* connection,
try
{
- (*the_slot)(Glib::wrap(connection, true), Glib::ustring(name));
+ (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name));
}
catch(...)
{
@@ -104,7 +104,7 @@ guint watch_name(
slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot);
return g_bus_watch_name(static_cast<GBusType>(bus_type), name.c_str(),
- static_cast<GBusNameWatcherFlags>(flags),
+ static_cast<GBusNameWatcherFlags>(flags),
&Bus_Name_Appeared_giomm_callback, &Bus_Name_Vanished_giomm_callback,
slots, &Bus_Watch_Name_giomm_callback_destroy);
}
@@ -124,7 +124,7 @@ guint watch_name(
slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot);
return g_bus_watch_name_on_connection(Glib::unwrap(connection),
- name.c_str(), static_cast<GBusNameWatcherFlags>(flags),
+ name.c_str(), static_cast<GBusNameWatcherFlags>(flags),
&Bus_Name_Appeared_giomm_callback, &Bus_Name_Vanished_giomm_callback,
slots, &Bus_Watch_Name_giomm_callback_destroy);
}
diff --git a/glib/src/fileutils.ccg b/glib/src/fileutils.ccg
index 77bd1f1..0fde698 100644
--- a/glib/src/fileutils.ccg
+++ b/glib/src/fileutils.ccg
@@ -95,7 +95,7 @@ DirIterator::DirIterator(GDir* gobject, const char* current)
std::string DirIterator::operator*() const
{
- return (current_) ? std::string(current_) : std::string();
+ return convert_const_gchar_ptr_to_ustring(current_);
}
DirIterator& DirIterator::operator++()
diff --git a/glib/src/iochannel.ccg b/glib/src/iochannel.ccg
index d800939..9405727 100644
--- a/glib/src/iochannel.ccg
+++ b/glib/src/iochannel.ccg
@@ -289,7 +289,7 @@ IOStatus IOChannel::set_encoding(const std::string& encoding)
std::string IOChannel::get_encoding() const
{
const char *const encoding = g_io_channel_get_encoding(gobject_);
- return (encoding) ? std::string(encoding) : std::string();
+ return convert_const_gchar_ptr_to_ustring(encoding);
}
void IOChannel::set_line_term(const std::string& term)
diff --git a/glib/src/markup.ccg b/glib/src/markup.ccg
index eb58f67..5c1b0f3 100644
--- a/glib/src/markup.ccg
+++ b/glib/src/markup.ccg
@@ -286,7 +286,7 @@ void ParseContext::end_parse()
Glib::ustring ParseContext::get_element() const
{
const char *const element_name = g_markup_parse_context_get_element(gobject_);
- return (element_name) ? Glib::ustring(element_name) : Glib::ustring();
+ return convert_const_gchar_ptr_to_ustring(element_name);
}
int ParseContext::get_line_number() const
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index 39509f0..f18f03c 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -223,7 +223,7 @@ Variant<Glib::ustring>::create(const Glib::ustring& data)
Glib::ustring Variant<Glib::ustring>::get() const
{
- return Glib::ustring(g_variant_get_string(gobject_, 0));
+ return convert_const_gchar_ptr_to_ustring(g_variant_get_string(gobject_, 0));
}
// Variant<Glib::ustring> makes sense for multiple types.
@@ -315,7 +315,7 @@ std::string Variant<std::string>::get() const
else //g_variant_get_string() cna handle strings, object paths, and signatures.
pch = g_variant_get_string(gobject_, 0);
- return std::string(pch);
+ return convert_const_gchar_ptr_to_stdstring(pch);
}
typedef std::vector<Glib::ustring> type_vec_ustring;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]