[evince/wip/bug654832: 9/18] [libdocument] Simplify code



commit 4bc902f077a3a20de6a7a28e18a15a07659b8ef0
Author: Christian Persch <chpe gnome org>
Date:   Sat Feb 13 22:14:51 2010 +0100

    [libdocument] Simplify code
    
    Construct the backends directory path in _ev_document_factory_init()
    directly.

 libdocument/ev-document-factory.c |   44 ++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 25 deletions(-)
---
diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c
index bb9064c..e8bac31 100644
--- a/libdocument/ev-document-factory.c
+++ b/libdocument/ev-document-factory.c
@@ -38,28 +38,7 @@
 /* Backends manager */
 
 static GList *ev_backends_list = NULL;
-
-static gchar *backendsdir = NULL;
-
-static const gchar *
-backends_dir (void)
-{
-	if (!backendsdir) {
-#ifdef G_OS_WIN32
-		gchar *dir;
-
-		dir = g_win32_get_package_installation_directory_of_module (NULL);
-		backendsdir = g_build_filename (dir, "lib", "evince",
-						EV_BACKENDSBINARYVERSION,
-						"backends", NULL);
-		g_free (dir);
-#else
-		backendsdir = g_strdup (EV_BACKENDSDIR);
-#endif
-	}
-
-	return backendsdir;
-}
+static gchar *ev_backends_dir = NULL;
 
 static EvBackendInfo *
 ev_document_factory_get_backend_info_for_mime_type (const gchar *mime_type)
@@ -95,7 +74,7 @@ ev_document_factory_new_document_for_mime_type (const gchar *mime_type)
         if (!info->module) {
                 gchar *path;
 
-                path = g_module_build_path (backends_dir(), info->module_name);
+                path = g_module_build_path (ev_backends_dir, info->module_name);
                 info->module = G_TYPE_MODULE (_ev_module_new (path, info->resident));
                 g_free (path);
         }
@@ -258,7 +237,21 @@ _ev_document_factory_init (void)
 	if (ev_backends_list)
 		return TRUE;
 
-        ev_backends_list = _ev_backend_info_load_from_dir (backends_dir ());
+#ifdef G_OS_WIN32
+{
+        gchar *dir;
+
+        dir = g_win32_get_package_installation_directory_of_module (NULL);
+        ev_backends_dir = g_build_filename (dir, "lib", "evince",
+                                        EV_BACKENDSBINARYVERSION,
+                                        "backends", NULL);
+        g_free (dir);
+}
+#else
+        ev_backends_dir = g_strdup (EV_BACKENDSDIR);
+#endif
+
+        ev_backends_list = _ev_backend_info_load_from_dir (ev_backends_dir);
 
         return ev_backends_list != NULL;
 }
@@ -275,7 +268,8 @@ _ev_document_factory_shutdown (void)
 	g_list_free (ev_backends_list);
 	ev_backends_list = NULL;
 
-	g_free (backendsdir);
+	g_free (ev_backends_dir);
+        ev_backends_dir = NULL;
 }
 
 /**



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