[PATCH 1/3] 730243 Consolidate GErrorSafePtr definitions (was Review of patch #730243 - Port to vte-2.91)
- From: Dodji Seketeli <dodji seketeli org>
- To: The mailing list of the Nemiver project <nemiver-list gnome org>
- Cc: rishi is lostca se
- Subject: [PATCH 1/3] 730243 Consolidate GErrorSafePtr definitions (was Review of patch #730243 - Port to vte-2.91)
- Date: Mon, 07 Jul 2014 21:47:48 +0200
Hey Debarshi,
As I was saying in the previous message, I have updated your first patch
and the patch below is the result. I have basically added the helper
functors to make SafePtr take GError in the nmv-safe-ptr-utils.h where
they belong.
The patch keeps your authorship, of course.
Cheers.
* src/common/nmv-ustring.cc: Remove local copy of GErrorSafePtr.
(wstring_to_ustring): Use GErrorSafePtr from nmv-error.h
instead of local copy.
(ustring_to_wstring): Likewise.
* src/confmgr/nmv-gconf-mgr.cc: Remove local copy of
GErrorSafePtr.
* src/common/nmv-safe-ptr-utils.h: Move the copy of
GErrorSafePtr definition here.
Signed-off-by: Dodji Seketeli <dodji seketeli org>
---
src/common/nmv-safe-ptr-utils.h | 18 +++++++++++++++++-
src/common/nmv-ustring.cc | 19 ++-----------------
src/confmgr/nmv-gconf-mgr.cc | 10 ----------
3 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/src/common/nmv-safe-ptr-utils.h b/src/common/nmv-safe-ptr-utils.h
index 27b0f85..fdeb350 100644
--- a/src/common/nmv-safe-ptr-utils.h
+++ b/src/common/nmv-safe-ptr-utils.h
@@ -99,13 +99,29 @@ struct DelUnicharsUnref {
}
};
+struct GErrorRef {
+ void
+ operator () (GError *)
+ {}
+};
+
+struct GErrorUnref {
+ void
+ operator () (GError *a_error)
+ {
+ if (a_error) {
+ g_error_free (a_error);
+ }
+ }
+};
+
typedef SafePtr <gchar, CharsRef, GCharUnref> GCharSafePtr;
typedef SafePtr <Object, ObjectRef, ObjectUnref> ObjectSafePtr;
typedef SafePtr <gchar, CharsRef, DelCharsUnref> CharSafePtr;
typedef SafePtr <gunichar, UnicharsRef, DelUnicharsUnref> UnicharSafePtr;
+typedef SafePtr<GError, GErrorRef, GErrorUnref> GErrorSafePtr;
NEMIVER_END_NAMESPACE(common)
NEMIVER_END_NAMESPACE(nemiver)
#endif
-
diff --git a/src/common/nmv-ustring.cc b/src/common/nmv-ustring.cc
index f5dfe49..41a1a26 100644
--- a/src/common/nmv-ustring.cc
+++ b/src/common/nmv-ustring.cc
@@ -479,21 +479,6 @@ WString::assign (super_type::size_type a_n, gunichar a_c)
return *this;
}
-struct GErrorRef {
- void operator () (GError *)
- {
- }
-};
-
-struct GErrorUnref {
- void operator () (GError *a_err)
- {
- if (a_err) {
- g_error_free (a_err);
- }
- }
-};
-
bool
wstring_to_ustring (const WString &a_wstr,
UString &a_ustr)
@@ -504,7 +489,7 @@ wstring_to_ustring (const WString &a_wstr,
utf8_buf.reset (g_ucs4_to_utf8 (a_wstr.c_str (),
a_wstr.size (), &wstr_len,
&utf8_bytes_len, &err));
- SafePtr<GError, GErrorRef, GErrorUnref> error;
+ GErrorSafePtr error;
error.reset (err);
if (error) {
LOG_ERROR ("got error conversion error: '" << error->message << "'");
@@ -531,7 +516,7 @@ ustring_to_wstring (const UString &a_ustr,
&utf8_bytes_len,
&wstr_len,
&err));
- SafePtr<GError, GErrorRef, GErrorUnref> error;
+ GErrorSafePtr error;
error.reset (err);
if (error) {
LOG_ERROR ("got error conversion error: '" << error->message << "'");
diff --git a/src/confmgr/nmv-gconf-mgr.cc b/src/confmgr/nmv-gconf-mgr.cc
index fd7ff1c..672935b 100644
--- a/src/confmgr/nmv-gconf-mgr.cc
+++ b/src/confmgr/nmv-gconf-mgr.cc
@@ -92,16 +92,6 @@ public:
//static const char * NEMIVER_KEY_DIR = "/app/nemiver";
-struct GErrorRef {
- void operator () (GError *a_error) {if (a_error) {}}
-};
-
-struct GErrorUnref {
- void operator () (GError *a_error) {if (a_error) {g_error_free (a_error);}}
-};
-
-typedef SafePtr<GError, GErrorRef, GErrorUnref> GErrorSafePtr;
-
void
client_notify_func (GConfClient *a_client,
const char* a_key,
--
Dodji
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]