=?utf-8?q?=5Bfolks=5D_Bug_664072_=E2=80=94_Folks_should_only_use_assert*?= =?utf-8?q?=28=29_for_critical=2C_program-terminating_errors?=
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Bug 664072 â Folks should only use assert*() for critical, program-terminating errors
- Date: Thu, 16 Aug 2012 23:03:44 +0000 (UTC)
commit 4ae4e6398af89b341f0b32da74cb6f91b9fb5176
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jul 30 12:03:21 2012 +0200
Bug 664072 â Folks should only use assert*() for critical, program-terminating errors
Turn various assert()s into return[_val]_if_fail()s.
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=664072
NEWS | 2 ++
backends/telepathy/lib/tpf-persona-store.vala | 3 ++-
folks/individual.vala | 14 +++++++-------
folks/potential-match.vala | 8 ++++----
4 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/NEWS b/NEWS
index 9fc2d2a..065a869 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Bugs fixed:
â Bug 681346 â Individual id can be inconsistent
â Bug 681420 â warning (vala 0.17.x): access to static class members through an
instance variable
+â Bug 664072 â Folks should only use assert*() for critical, program-terminating
+ errors
Overview of changes from libfolks 0.7.2 to libfolks 0.7.3
=========================================================
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index bbff7c3..3fb9809 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -1554,7 +1554,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
}
/* Bail if a store already exists for this account. */
- assert (!PersonaStore._persona_stores_by_account.has_key (store.id));
+ return_if_fail (
+ !PersonaStore._persona_stores_by_account.has_key (store.id));
/* Add the store. */
PersonaStore._persona_stores_by_account.set (store.id, store);
diff --git a/folks/individual.vala b/folks/individual.vala
index d0bd428..e087b25 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -1258,8 +1258,8 @@ public class Folks.Individual : Object,
{
CompareDataFunc<Persona> primary_compare_func = (a, b) =>
{
- assert (a != null);
- assert (b != null);
+ return_val_if_fail (a != null, 0);
+ return_val_if_fail (b != null, 0);
/* Always prefer values which are set over those which aren't. */
var a_is_set = filter_func (a);
@@ -1446,7 +1446,7 @@ public class Folks.Individual : Object,
this._update_single_valued_property (typeof (AliasDetails), (p) =>
{
var alias = ((AliasDetails) p).alias;
- assert (alias != null);
+ return_val_if_fail (alias != null, false);
return (alias.strip () != ""); /* empty aliases are unset */
}, (a, b) =>
@@ -1454,8 +1454,8 @@ public class Folks.Individual : Object,
var a_alias = ((AliasDetails) a).alias;
var b_alias = ((AliasDetails) b).alias;
- assert (a_alias != null);
- assert (b_alias != null);
+ return_val_if_fail (a_alias != null, 0);
+ return_val_if_fail (b_alias != null, 0);
var a_is_empty = (a_alias.strip () == "") ? 1 : 0;
var b_is_empty = (b_alias.strip () == "") ? 1 : 0;
@@ -1670,7 +1670,7 @@ public class Folks.Individual : Object,
this._update_single_valued_property (typeof (NameDetails), (p) =>
{
var name = ((NameDetails) p).full_name;
- assert (name != null);
+ return_val_if_fail (name != null, false);
return (name.strip () != ""); /* empty names are unset */
}, (a, b) =>
@@ -1699,7 +1699,7 @@ public class Folks.Individual : Object,
this._update_single_valued_property (typeof (NameDetails), (p) =>
{
var nickname = ((NameDetails) p).nickname;
- assert (nickname != null);
+ return_val_if_fail (nickname != null, false);
return (nickname.strip () != ""); /* empty names are unset */
}, (a, b) =>
diff --git a/folks/potential-match.vala b/folks/potential-match.vala
index aa58df9..31eac72 100644
--- a/folks/potential-match.vala
+++ b/folks/potential-match.vala
@@ -473,8 +473,8 @@ public class Folks.PotentialMatch : Object
return false;
}
- assert (a.validate ());
- assert (b.validate ());
+ return_val_if_fail (a.validate (), false);
+ return_val_if_fail (b.validate (), false);
var a_stripped = this._strip_string ((!) a);
var b_stripped = this._strip_string ((!) b);
@@ -499,8 +499,8 @@ public class Folks.PotentialMatch : Object
return false;
}
- assert (a.validate ());
- assert (b.validate ());
+ return_val_if_fail (a.validate (), false);
+ return_val_if_fail (b.validate (), false);
var a_stripped = this._strip_string ((!) a);
var b_stripped = this._strip_string ((!) b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]