[PATCH 2/3] Consolidate NativeGObjectSafePtr 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 2/3] Consolidate NativeGObjectSafePtr definitions (was: Review of patch #730243 - Port to vte-2.91)
- Date: Mon, 07 Jul 2014 21:54:31 +0200
This second patch of the set adds SafePtr functors to make SafePtr work
with native GObject pointers. I needed this to make the later changes
of porting the terminal widget of Nemiver be exception safe.
Cheers.
* src/persp/dbgperspective/nmv-dbg-perspective.cc
(RefGObjectNative, UnrefGObjectNative): Move the definition of
these functors ...
* src/common/nmv-safe-ptr-utils.h: ... here.
Signed-off-by: Dodji Seketeli <dodji seketeli org>
---
src/common/nmv-safe-ptr-utils.h | 23 ++++++++++++++++++++++-
src/persp/dbgperspective/nmv-dbg-perspective.cc | 18 ------------------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/common/nmv-safe-ptr-utils.h b/src/common/nmv-safe-ptr-utils.h
index fdeb350..72211e8 100644
--- a/src/common/nmv-safe-ptr-utils.h
+++ b/src/common/nmv-safe-ptr-utils.h
@@ -30,7 +30,7 @@
#ifndef __NMV_SAFE_PTR_UTILS_H__
#define __NMV_SAFE_PTR_UTILS_H__
-#include <glib.h>
+#include <glib-object.h>
#include "nmv-object.h"
#include "nmv-safe-ptr.h"
#include "nmv-namespace.h"
@@ -115,11 +115,32 @@ struct GErrorUnref {
}
};
+struct RefGObjectNative {
+ void operator () (void *a_object)
+ {
+ if (a_object && G_IS_OBJECT (a_object)) {
+ g_object_ref (G_OBJECT (a_object));
+ }
+ }
+};
+
+struct UnrefGObjectNative {
+ void operator () (void *a_object)
+ {
+ if (a_object && G_IS_OBJECT (a_object)) {
+ g_object_unref (G_OBJECT (a_object));
+ }
+ }
+};
+
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;
+typedef SafePtr<void*,
+ RefGObjectNative,
+ UnrefGObjectNative> NativeGObjectSafePtr;
NEMIVER_END_NAMESPACE(common)
NEMIVER_END_NAMESPACE(nemiver)
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 6e07ce7..6a7ff1b 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -836,24 +836,6 @@ struct UnrefGObject {
}
};
-struct RefGObjectNative {
- void operator () (void *a_object)
- {
- if (a_object && G_IS_OBJECT (a_object)) {
- g_object_ref (G_OBJECT (a_object));
- }
- }
-};
-
-struct UnrefGObjectNative {
- void operator () (void *a_object)
- {
- if (a_object && G_IS_OBJECT (a_object)) {
- g_object_unref (G_OBJECT (a_object));
- }
- }
-};
-
static
void gio_file_monitor_cb (const Glib::RefPtr<Gio::File>& file,
const Glib::RefPtr<Gio::File>& other_file,
--
Dodji
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]