From 88ae241f9ed612041aa97fb0027d95169f89a026 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Tue, 9 May 2006 18:00:47 +0000 Subject: [PATCH] Fix some memory leaks. 2006-05-09 Carlos Garcia Campos * pdf/ev-poppler.cc: * shell/ev-application.[ch]: * shell/main.c: Fix some memory leaks. --- ChangeLog | 8 ++++++++ pdf/ev-poppler.cc | 1 + shell/ev-application.c | 14 +++++++++----- shell/ev-application.h | 1 - shell/main.c | 12 ++++++++++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb53f525..d56e8fb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-05-09 Carlos Garcia Campos + + * pdf/ev-poppler.cc: + * shell/ev-application.[ch]: + * shell/main.c: + + Fix some memory leaks. + 2006-05-09 Wouter Bolsterlee * shell/ev-properties-dialog.c: (ev_properties_dialog_init): diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 5c2f54d6..a3d38726 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -964,6 +964,7 @@ build_tree (PdfDocument *pdf_document, if (child) build_tree (pdf_document, model, &tree_iter, child); poppler_index_iter_free (child); + poppler_action_free (action); } while (poppler_index_iter_next (iter)); } diff --git a/shell/ev-application.c b/shell/ev-application.c index de5e3a0c..ffa58ee7 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -46,20 +46,22 @@ G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT); -#define EV_APPLICATION_GET_PRIVATE(object) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_APPLICATION, EvApplicationPrivate)) - #define APPLICATION_SERVICE_NAME "org.gnome.evince.ApplicationService" #ifdef ENABLE_DBUS gboolean ev_application_register_service (EvApplication *application) { - DBusGConnection *connection; + static DBusGConnection *connection = NULL; DBusGProxy *driver_proxy; GError *err = NULL; guint request_name_result; + if (connection) { + g_warning ("Service already registered."); + return FALSE; + } + connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err); if (connection == NULL) { g_warning ("Service registration failed."); @@ -90,6 +92,8 @@ ev_application_register_service (EvApplication *application) } #endif + g_object_unref (driver_proxy); + if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) { return FALSE; } @@ -325,7 +329,7 @@ ev_application_shutdown (EvApplication *application) g_object_unref (application->recent_model); application->recent_model = NULL; } - + g_free (application->last_chooser_uri); g_object_unref (application); diff --git a/shell/ev-application.h b/shell/ev-application.h index 2202a9a3..0c562c0b 100644 --- a/shell/ev-application.h +++ b/shell/ev-application.h @@ -35,7 +35,6 @@ G_BEGIN_DECLS typedef struct _EvApplication EvApplication; typedef struct _EvApplicationClass EvApplicationClass; -typedef struct _EvApplicationPrivate EvApplicationPrivate; #define EV_TYPE_APPLICATION (ev_application_get_type ()) #define EV_APPLICATION(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_APPLICATION, EvApplication)) diff --git a/shell/main.c b/shell/main.c index 3a38986b..91a62d25 100644 --- a/shell/main.c +++ b/shell/main.c @@ -158,6 +158,8 @@ load_files_remote (const char **files) if (!dbus_g_proxy_end_call (remote_object, call, &error, DBUS_TYPE_INVALID)) { g_warning (error->message); g_clear_error (&error); + g_object_unref (remote_object); + dbus_g_connection_unref (connection); return FALSE; } #elif DBUS_VERSION == 34 @@ -168,6 +170,8 @@ load_files_remote (const char **files) if (!dbus_g_proxy_end_call (remote_object, call, &error, G_TYPE_INVALID)) { g_warning (error->message); g_clear_error (&error); + g_object_unref (remote_object); + dbus_g_connection_unref (connection); return FALSE; } #else @@ -177,9 +181,14 @@ load_files_remote (const char **files) G_TYPE_INVALID)) { g_warning (error->message); g_clear_error (&error); + g_object_unref (remote_object); + dbus_g_connection_unref (connection); return FALSE; } #endif + g_object_unref (remote_object); + dbus_g_connection_unref (connection); + return TRUE; } @@ -232,6 +241,9 @@ load_files_remote (const char **files) result = TRUE; } + g_object_unref (remote_object); + dbus_g_connection_unref (connection); + gdk_notify_startup_complete (); return result; -- 2.43.5