]> git.0d.be Git - empathy.git/commitdiff
Fix warnings when finalizing.
authorXavier Claessens <xclaesse@gmail.com>
Fri, 21 Sep 2007 12:24:24 +0000 (12:24 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 21 Sep 2007 12:24:24 +0000 (12:24 +0000)
2007-09-21  Xavier Claessens  <xclaesse@gmail.com>

* libempathy/empathy-tp-contact-list.c: Fix warnings when finalizing.

* tests/contact-manager.c:
* tests/Makefile.am:
* configure.ac:
* Makefile.am: Add a test program to track leaks.

svn path=/trunk/; revision=304

ChangeLog
Makefile.am
configure.ac
libempathy/empathy-tp-contact-list.c
tests/Makefile.am [new file with mode: 0644]
tests/contact-manager.c [new file with mode: 0644]

index f7330eb448b8d37784b361b678a1b7ecfea9eba2..8bf030565d1a10600225ae66ea91179a6a272315 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-09-21  Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy/empathy-tp-contact-list.c: Fix warnings when finalizing.
+
+       * tests/contact-manager.c:
+       * tests/Makefile.am:
+       * configure.ac:
+       * Makefile.am: Add a test program to track leaks.
+
 2007-09-21  Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-contact-list-view.c: Fix ref count error for
index f809c10282cbf18de77d3707daa4ddc2418327b2..3743916f56c996e870703b78c3ef0d5d57f00cb6 100644 (file)
@@ -12,6 +12,10 @@ if HAVE_PYTHON
 SUBDIRS += python
 endif
 
+if HAVE_TESTS
+SUBDIRS += tests
+endif
+
 DISTCHECK_CONFIGURE_FLAGS =    \
        --disable-scrollkeeper  \
        --enable-gtk-doc
index a3e865f28d990da861bdaf970e27965df59389f3..bade8bb304ca82ecda0af43e16bcdc9525a6ba1a 100644 (file)
@@ -204,6 +204,16 @@ fi
 
 AM_CONDITIONAL(HAVE_NOTHERE, test "x$have_nothere" = "xyes")
 
+dnl -----------------------------------------------------------
+dnl Tests
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE(tests,
+              AS_HELP_STRING([--enable-tests=@<:@no/yes@:>@],
+                             [build tests]), ,
+                             enable_tests=no)
+
+AM_CONDITIONAL(HAVE_TESTS, test "x$enable_tests" = "xyes")
+
 dnl -----------------------------------------------------------
 dnl Python Bindings
 dnl -----------------------------------------------------------
@@ -271,4 +281,5 @@ AC_OUTPUT([
    python/Makefile
    python/pyempathy/Makefile
    python/pyempathygtk/Makefile
+   tests/Makefile
 ])
index 16ecad80774dd46823e5fcff442151ae19bd411b..ae178dd068099467a5c5c76db4d9647009c36e6a 100644 (file)
@@ -492,11 +492,19 @@ tp_contact_list_newchannel_cb (DBusGProxy           *proxy,
 }
 
 static void
-tp_contact_list_remove_all (EmpathyTpContactList *list)
+tp_contact_list_destroy_cb (TpConn               *tp_conn,
+                           EmpathyTpContactList *list)
 {
        EmpathyTpContactListPriv *priv = GET_PRIV (list);
        GList                    *l;
 
+       empathy_debug (DEBUG_DOMAIN, "Account disconnected or CM crashed");
+
+       /* DBus proxie should NOT be used anymore */
+       g_object_unref (priv->tp_conn);
+       priv->tp_conn = NULL;
+
+       /* Remove all contacts */
        for (l = priv->members; l; l = l->next) {
                g_signal_emit_by_name (list, "members-changed", l->data,
                                       NULL, 0, NULL,
@@ -509,26 +517,10 @@ tp_contact_list_remove_all (EmpathyTpContactList *list)
                                       FALSE);
                g_object_unref (l->data);
        }
-
        g_list_free (priv->members);
        g_list_free (priv->pendings);
        priv->members = NULL;
        priv->pendings = NULL;
-}
-
-static void
-tp_contact_list_destroy_cb (TpConn               *tp_conn,
-                           EmpathyTpContactList *list)
-{
-       EmpathyTpContactListPriv *priv = GET_PRIV (list);
-
-       empathy_debug (DEBUG_DOMAIN, "Account disconnected or CM crashed");
-
-       /* DBus proxie should NOT be used anymore */
-       g_object_unref (priv->tp_conn);
-       priv->tp_conn = NULL;
-
-       tp_contact_list_remove_all (list);
 
        /* Tell the world to not use us anymore */
        g_signal_emit (list, signals[DESTROY], 0);
@@ -591,7 +583,6 @@ tp_contact_list_finalize (GObject *object)
        empathy_debug (DEBUG_DOMAIN, "finalize: %p", object);
 
        tp_contact_list_disconnect (list);
-       tp_contact_list_remove_all (list);
 
        if (priv->mc) {
                dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
@@ -617,6 +608,10 @@ tp_contact_list_finalize (GObject *object)
        g_hash_table_destroy (priv->contacts_groups);
        g_list_foreach (priv->groups, (GFunc) g_object_unref, NULL);
        g_list_free (priv->groups);
+       g_list_foreach (priv->members, (GFunc) g_object_unref, NULL);
+       g_list_free (priv->members);
+       g_list_foreach (priv->pendings, (GFunc) g_object_unref, NULL);
+       g_list_free (priv->pendings);
 
        G_OBJECT_CLASS (empathy_tp_contact_list_parent_class)->finalize (object);
 }
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..1635859
--- /dev/null
@@ -0,0 +1,15 @@
+AM_CPPFLAGS =                                          \
+       -I$(top_srcdir)                                 \
+       $(EMPATHY_CFLAGS)                               \
+       $(WARN_CFLAGS)
+
+LDADD =                                                                \
+       $(top_builddir)/libempathy-gtk/libempathy-gtk.la        \
+       $(top_builddir)/libempathy/libempathy.la                \
+       $(EMPATHY_LIBS)
+
+noinst_PROGRAMS =                      \
+       contact-manager
+
+contact_manager_SOURCES = contact-manager.c
+
diff --git a/tests/contact-manager.c b/tests/contact-manager.c
new file mode 100644 (file)
index 0000000..c945010
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <libempathy/empathy-contact-manager.h>
+
+static gboolean
+time_out (gpointer data)
+{
+       gtk_main_quit ();
+
+       return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+       EmpathyContactManager *manager;
+
+       gtk_init (&argc, &argv);
+
+       manager = empathy_contact_manager_new ();
+       
+       g_timeout_add (5000, time_out, NULL);
+
+       gtk_main ();
+       
+       g_object_unref (manager);
+
+       return EXIT_SUCCESS;
+}