[ekiga] AddressBook: Make sure the Ekiga::Source are destroyed properly on quit.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] AddressBook: Make sure the Ekiga::Source are destroyed properly on quit.
- Date: Sun, 15 Mar 2015 15:45:15 +0000 (UTC)
commit c49ddaf204331e4232a83543be6411c3c51785fe
Author: Damien Sandras <dsandras seconix com>
Date: Sun Feb 8 13:03:25 2015 +0100
AddressBook: Make sure the Ekiga::Source are destroyed properly on quit.
We were binding shared_ptr to the Source objects signals.
That means that the shared_ptr are garbage collected at a later stage,
at least with boost::signals2, which is not what we want. One solution
would be to use weak_ptr's. However, we are not really using the Source
share_ptr in any of our callbacks, so simplifying the signals signature
seems to be a better idea.
lib/engine/addressbook/contact-core.cpp | 20 ++++++++---
lib/engine/addressbook/contact-core.h | 13 ++++---
lib/engine/gui/gtk-frontend/addressbook-window.cpp | 34 +++++++-------------
3 files changed, 33 insertions(+), 34 deletions(-)
---
diff --git a/lib/engine/addressbook/contact-core.cpp b/lib/engine/addressbook/contact-core.cpp
index 5b2e1a8..5c5b1eb 100644
--- a/lib/engine/addressbook/contact-core.cpp
+++ b/lib/engine/addressbook/contact-core.cpp
@@ -34,6 +34,8 @@
#include <glib/gi18n.h>
+#include "config.h"
+
#include "contact-core.h"
/*
@@ -44,6 +46,12 @@ on_search ()
}
*/
+Ekiga::ContactCore::~ContactCore ()
+{
+#if DEBUG
+ std::cout << "Ekiga::ConcactCore: Destructor invoked" << std::endl << std::flush;
+#endif
+}
void
Ekiga::ContactCore::add_source (SourcePtr source)
@@ -51,12 +59,12 @@ Ekiga::ContactCore::add_source (SourcePtr source)
sources.push_back (source);
source_added (source);
conns.add (source->updated.connect (boost::ref (updated)));
- conns.add (source->book_added.connect (boost::bind (boost::ref (book_added), source, _1)));
- conns.add (source->book_removed.connect (boost::bind (boost::ref (book_removed), source, _1)));
- conns.add (source->book_updated.connect (boost::bind (boost::ref (book_updated), source, _1)));
- conns.add (source->contact_added.connect (boost::bind (boost::ref (contact_added), source, _1, _2)));
- conns.add (source->contact_removed.connect (boost::bind (boost::ref (contact_removed), source, _1, _2)));
- conns.add (source->contact_updated.connect (boost::bind (boost::ref (contact_updated), source, _1, _2)));
+ conns.add (source->book_added.connect (boost::bind (boost::ref (book_added), _1)));
+ conns.add (source->book_removed.connect (boost::bind (boost::ref (book_removed), _1)));
+ conns.add (source->book_updated.connect (boost::bind (boost::ref (book_updated), _1)));
+ conns.add (source->contact_added.connect (boost::bind (boost::ref (contact_added), _1, _2)));
+ conns.add (source->contact_removed.connect (boost::bind (boost::ref (contact_removed), _1, _2)));
+ conns.add (source->contact_updated.connect (boost::bind (boost::ref (contact_updated), _1, _2)));
source->questions.connect (boost::ref (questions));
updated ();
diff --git a/lib/engine/addressbook/contact-core.h b/lib/engine/addressbook/contact-core.h
index 3b45000..70a6403 100644
--- a/lib/engine/addressbook/contact-core.h
+++ b/lib/engine/addressbook/contact-core.h
@@ -67,6 +67,7 @@ namespace Ekiga
ContactCore ()
{}
+ ~ContactCore ();
/*** Service Implementation ***/
@@ -108,32 +109,32 @@ namespace Ekiga
/** This signal is emitted when a book has been added to one of
* the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr )> book_added;
+ boost::signals2::signal<void(BookPtr)> book_added;
/** This signal is emitted when a book has been removed from one of
* the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr )> book_removed;
+ boost::signals2::signal<void(BookPtr )> book_removed;
/** This signal is emitted when a book has been updated in one of
* the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr )> book_updated;
+ boost::signals2::signal<void(BookPtr )> book_updated;
/** This signal is emitted when a contact has been added to one of
* the book of one of the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr, ContactPtr )> contact_added;
+ boost::signals2::signal<void(BookPtr, ContactPtr )> contact_added;
/** This signal is emitted when a contact has been removed from one of
* the book of one of the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr, ContactPtr )> contact_removed;
+ boost::signals2::signal<void(BookPtr, ContactPtr )> contact_removed;
/** This signal is emitted when a contact has been updated in one of
* the book of one of the sources
*/
- boost::signals2::signal<void(SourcePtr, BookPtr, ContactPtr )> contact_updated;
+ boost::signals2::signal<void(BookPtr, ContactPtr )> contact_updated;
private:
diff --git a/lib/engine/gui/gtk-frontend/addressbook-window.cpp
b/lib/engine/gui/gtk-frontend/addressbook-window.cpp
index 1315d72..936b303 100644
--- a/lib/engine/gui/gtk-frontend/addressbook-window.cpp
+++ b/lib/engine/gui/gtk-frontend/addressbook-window.cpp
@@ -114,8 +114,7 @@ static bool visit_books (Ekiga::BookPtr book,
* BEHAVIOR : Add a view of the Book in the AddressBookWindow.
* PRE : The given GtkWidget pointer must be an SearchBook GObject.
*/
-static void on_book_added (Ekiga::SourcePtr source,
- Ekiga::BookPtr book,
+static void on_book_added (Ekiga::BookPtr book,
gpointer data);
@@ -124,8 +123,7 @@ static void on_book_added (Ekiga::SourcePtr source,
* BEHAVIOR : Remove the view of the Book from the AddressBookWindow.
* PRE : The given GtkWidget pointer must be an SearchBook GObject.
*/
-static void on_book_removed (Ekiga::SourcePtr source,
- Ekiga::BookPtr book,
+static void on_book_removed (Ekiga::BookPtr book,
gpointer data);
@@ -134,8 +132,7 @@ static void on_book_removed (Ekiga::SourcePtr source,
* BEHAVIOR : Update the Book in the AddressBookWindow.
* PRE : The given GtkWidget pointer must be an SearchBook GObject.
*/
-static void on_book_updated (Ekiga::SourcePtr source,
- Ekiga::BookPtr book,
+static void on_book_updated (Ekiga::BookPtr book,
gpointer data);
/* DESCRIPTION : Called when the ContactCore has a form request
@@ -286,18 +283,17 @@ on_source_added (Ekiga::SourcePtr source,
static bool visit_books (Ekiga::BookPtr book,
- Ekiga::SourcePtr source,
+ G_GNUC_UNUSED Ekiga::SourcePtr source,
gpointer data)
{
- on_book_added (source, book, data);
+ on_book_added (book, data);
return true;
}
static void
-on_book_added (Ekiga::SourcePtr /*source*/,
- Ekiga::BookPtr book,
+on_book_added (Ekiga::BookPtr book,
gpointer data)
{
addressbook_window_add_book (ADDRESSBOOK_WINDOW (data), book);
@@ -305,8 +301,7 @@ on_book_added (Ekiga::SourcePtr /*source*/,
static void
-on_book_removed (Ekiga::SourcePtr /*source*/,
- Ekiga::BookPtr book,
+on_book_removed (Ekiga::BookPtr book,
gpointer data)
{
addressbook_window_remove_book (ADDRESSBOOK_WINDOW (data), book);
@@ -314,8 +309,7 @@ on_book_removed (Ekiga::SourcePtr /*source*/,
static void
-on_book_updated (Ekiga::SourcePtr /*source*/,
- Ekiga::BookPtr book,
+on_book_updated (Ekiga::BookPtr book,
gpointer data)
{
addressbook_window_update_book (ADDRESSBOOK_WINDOW (data), book);
@@ -783,20 +777,16 @@ addressbook_window_new (GmApplication *app)
gtk_widget_show_all (GTK_WIDGET (hpaned));
/* Signals */
- conn = contact_core->source_added.connect (boost::bind (&on_source_added,
- _1, (gpointer) self));
+ conn = contact_core->source_added.connect (boost::bind (&on_source_added, _1, (gpointer) self));
self->priv->connections.add (conn);
- conn = contact_core->book_updated.connect (boost::bind (&on_book_updated,
- _1, _2, (gpointer) self));
+ conn = contact_core->book_updated.connect (boost::bind (&on_book_updated, _1, (gpointer) self));
self->priv->connections.add (conn);
- conn = contact_core->book_added.connect (boost::bind (&on_book_added,
- _1, _2, (gpointer) self));
+ conn = contact_core->book_added.connect (boost::bind (&on_book_added, _1, (gpointer) self));
self->priv->connections.add (conn);
- conn = contact_core->book_removed.connect (boost::bind (&on_book_removed,
- _1, _2, (gpointer) self));
+ conn = contact_core->book_removed.connect (boost::bind (&on_book_removed, _1, (gpointer) self));
self->priv->connections.add (conn);
conn = contact_core->questions.connect (boost::bind (&on_handle_questions, _1, (gpointer) self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]