diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2013-05-13 21:33:34 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2013-05-16 11:19:32 +0200 |
commit | d3eee8a0390558795ace8be503b44d76be385b13 (patch) | |
tree | 1a6d9442af43632cb2e1db172653f97dd005c4b1 /src/dbus/server/pim/locale-factory-boost.cpp | |
parent | fb83c468a8ba554e40bb5fbb746154fd1d6cd0c2 (diff) |
glib: stricter ref counting
Following the boost::instrusive_ptr example and making "add_ref =
true" the default in our CXX GLib and GObject wrappers led to some
memory leaks because it didn't enforce thinking about whether the
plain pointer is already owned by us or not.
It is better to use a mandatory enum value, ADD_REF and TRANSFER_REF,
and force explicit construction. Doing that revealed that the
assignment operator was implemented as constructing a CXX instance
with increased ref count and/or that in some places, a real leak was
caused by increasing the ref count unnecessarily.
Running under valgrind gave a false sense of security. Some of the
real leaks only showed up randomly in tests.
Diffstat (limited to 'src/dbus/server/pim/locale-factory-boost.cpp')
-rw-r--r-- | src/dbus/server/pim/locale-factory-boost.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dbus/server/pim/locale-factory-boost.cpp b/src/dbus/server/pim/locale-factory-boost.cpp index b266b19b..accf142d 100644 --- a/src/dbus/server/pim/locale-factory-boost.cpp +++ b/src/dbus/server/pim/locale-factory-boost.cpp @@ -370,7 +370,7 @@ public: // to the search term. e_book_query_field_test(E_CONTACT_TEL, E_BOOK_QUERY_EQUALS_NATIONAL_PHONE_NUMBER, m_tel.c_str()), - false); + TRANSFER_REF); PlainGStr filter(e_book_query_to_string(query.get())); return filter.get(); } @@ -554,7 +554,7 @@ public: // // We restore the right order by sorting, which puts the // country code first, and then joining. - GeeCollectionCXX coll(folks_abstract_field_details_get_parameter_values(phone, "x-evolution-e164"), false); + GeeCollectionCXX coll(folks_abstract_field_details_get_parameter_values(phone, "x-evolution-e164"), TRANSFER_REF); if (coll) { std::vector<std::string> components; components.reserve(2); |