[latexila] Move singleton instance variables inside get_instance() functions



commit 69ad31f3620cf02f60305171ad9588587e51f023
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Apr 8 18:03:34 2015 +0200

    Move singleton instance variables inside get_instance() functions
    
    So that the variable is declared in the same place where it is used,
    which is much simpler to understand the code.

 src/liblatexila/latexila-build-tools-default.c  |    4 ++--
 src/liblatexila/latexila-build-tools-personal.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/liblatexila/latexila-build-tools-default.c b/src/liblatexila/latexila-build-tools-default.c
index 38df426..4a787a6 100644
--- a/src/liblatexila/latexila-build-tools-default.c
+++ b/src/liblatexila/latexila-build-tools-default.c
@@ -37,8 +37,6 @@
 #include "latexila-build-tools-default.h"
 #include <gio/gio.h>
 
-static LatexilaBuildToolsDefault *instance = NULL;
-
 struct _LatexilaBuildToolsDefaultPrivate
 {
   gint something; /* not used, but the struct can not be empty */
@@ -214,6 +212,8 @@ latexila_build_tools_default_init (LatexilaBuildToolsDefault *build_tools)
 LatexilaBuildToolsDefault *
 latexila_build_tools_default_get_instance (void)
 {
+  static LatexilaBuildToolsDefault *instance = NULL;
+
   if (instance == NULL)
     instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_DEFAULT, NULL);
 
diff --git a/src/liblatexila/latexila-build-tools-personal.c b/src/liblatexila/latexila-build-tools-personal.c
index f330201..bb7d76b 100644
--- a/src/liblatexila/latexila-build-tools-personal.c
+++ b/src/liblatexila/latexila-build-tools-personal.c
@@ -31,8 +31,6 @@
 #include <gio/gio.h>
 #include "latexila-build-tool.h"
 
-static LatexilaBuildToolsPersonal *instance = NULL;
-
 struct _LatexilaBuildToolsPersonalPrivate
 {
   /* Used for saving */
@@ -115,6 +113,8 @@ latexila_build_tools_personal_init (LatexilaBuildToolsPersonal *build_tools)
 LatexilaBuildToolsPersonal *
 latexila_build_tools_personal_get_instance (void)
 {
+  static LatexilaBuildToolsPersonal *instance = NULL;
+
   if (instance == NULL)
     instance = g_object_new (LATEXILA_TYPE_BUILD_TOOLS_PERSONAL, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]