[gtksourceview/wip/destructor] Use a DSO destructor to unref singletons
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/destructor] Use a DSO destructor to unref singletons
- Date: Tue, 2 Aug 2016 05:57:49 +0000 (UTC)
commit 8e9ae577298e5eac9f68767dbc2f5652d77b7ac7
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Aug 2 07:54:59 2016 +0200
Use a DSO destructor to unref singletons
gtksourceview/gtksourcestyleschememanager.c | 20 +++++++++++++-------
gtksourceview/gtksourcestyleschememanager.h | 4 ++++
2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gtksourceview/gtksourcestyleschememanager.c b/gtksourceview/gtksourcestyleschememanager.c
index 161536e..eeae1fd 100644
--- a/gtksourceview/gtksourcestyleschememanager.c
+++ b/gtksourceview/gtksourcestyleschememanager.c
@@ -57,6 +57,8 @@ enum {
PROP_SCHEME_IDS
};
+static GtkSourceStyleSchemeManager *default_instance;
+
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceStyleSchemeManager, gtk_source_style_scheme_manager, G_TYPE_OBJECT)
static void
@@ -202,16 +204,20 @@ gtk_source_style_scheme_manager_new (void)
GtkSourceStyleSchemeManager *
gtk_source_style_scheme_manager_get_default (void)
{
- static GtkSourceStyleSchemeManager *instance;
-
- if (instance == NULL)
+ if (default_instance == NULL)
{
- instance = gtk_source_style_scheme_manager_new ();
- g_object_add_weak_pointer (G_OBJECT (instance),
- (gpointer) &instance);
+ default_instance = gtk_source_style_scheme_manager_new ();
+ g_object_add_weak_pointer (G_OBJECT (default_instance),
+ (gpointer) &default_instance);
}
- return instance;
+ return default_instance;
+}
+
+GtkSourceStyleSchemeManager *
+_gtk_source_style_scheme_manager_peek_default (void)
+{
+ return default_instance;
}
static gboolean
diff --git a/gtksourceview/gtksourcestyleschememanager.h b/gtksourceview/gtksourcestyleschememanager.h
index ed35d0a..9c3a56a 100644
--- a/gtksourceview/gtksourcestyleschememanager.h
+++ b/gtksourceview/gtksourcestyleschememanager.h
@@ -74,6 +74,10 @@ GTK_SOURCE_AVAILABLE_IN_ALL
GtkSourceStyleSchemeManager *
gtk_source_style_scheme_manager_get_default (void);
+G_GNUC_INTERNAL
+GtkSourceStyleSchemeManager *
+ _gtk_source_style_scheme_manager_peek_default (void);
+
GTK_SOURCE_AVAILABLE_IN_ALL
void gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager
*manager,
gchar
**path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]