[gnome-photos/wip/rishi/manager-model: 3/6] base-manager: Be more strict about what is acceptable
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/manager-model: 3/6] base-manager: Be more strict about what is acceptable
- Date: Sat, 5 Nov 2016 08:49:21 +0000 (UTC)
commit 289c01af041a52e15dcc8e3b9bbc834a31e73342
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Oct 13 07:12:39 2016 +0200
base-manager: Be more strict about what is acceptable
src/photos-base-manager.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index dd71022..b5da8ad 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -324,6 +324,9 @@ photos_base_manager_new (void)
void
photos_base_manager_add_object (PhotosBaseManager *self, GObject *object)
{
+ g_return_if_fail (PHOTOS_IS_BASE_MANAGER (self));
+ g_return_if_fail (PHOTOS_IS_FILTERABLE (object));
+
PHOTOS_BASE_MANAGER_GET_CLASS (self)->add_object (self, object);
}
@@ -333,6 +336,8 @@ photos_base_manager_clear (PhotosBaseManager *self)
{
PhotosBaseManagerPrivate *priv;
+ g_return_if_fail (PHOTOS_IS_BASE_MANAGER (self));
+
priv = photos_base_manager_get_instance_private (self);
g_hash_table_remove_all (priv->objects);
@@ -346,6 +351,8 @@ photos_base_manager_get_action_id (PhotosBaseManager *self)
{
PhotosBaseManagerPrivate *priv;
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+
priv = photos_base_manager_get_instance_private (self);
return priv->action_id;
}
@@ -354,6 +361,7 @@ photos_base_manager_get_action_id (PhotosBaseManager *self)
GObject *
photos_base_manager_get_active_object (PhotosBaseManager *self)
{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_active_object (self);
}
@@ -371,6 +379,8 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
guint i;
guint length;
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+
priv = photos_base_manager_get_instance_private (self);
values = g_hash_table_get_values (priv->objects);
@@ -417,6 +427,7 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
gchar *
photos_base_manager_get_filter (PhotosBaseManager *self, gint flags)
{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_filter (self, flags);
}
@@ -424,6 +435,9 @@ photos_base_manager_get_filter (PhotosBaseManager *self, gint flags)
GObject *
photos_base_manager_get_object_by_id (PhotosBaseManager *self, const gchar *id)
{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+ g_return_val_if_fail (id != NULL && id[0] != '\0', NULL);
+
return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_object_by_id (self, id);
}
@@ -431,6 +445,7 @@ photos_base_manager_get_object_by_id (PhotosBaseManager *self, const gchar *id)
GHashTable *
photos_base_manager_get_objects (PhotosBaseManager *self)
{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_objects (self);
}
@@ -441,6 +456,8 @@ photos_base_manager_get_objects_count (PhotosBaseManager *self)
PhotosBaseManagerPrivate *priv;
guint count;
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), 0);
+
priv = photos_base_manager_get_instance_private (self);
count = g_hash_table_size (priv->objects);
return count;
@@ -452,6 +469,8 @@ photos_base_manager_get_title (PhotosBaseManager *self)
{
PhotosBaseManagerPrivate *priv;
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+
priv = photos_base_manager_get_instance_private (self);
return priv->title;
}
@@ -460,6 +479,7 @@ photos_base_manager_get_title (PhotosBaseManager *self)
gchar *
photos_base_manager_get_where (PhotosBaseManager *self, gint flags)
{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_where (self, flags);
}
@@ -472,6 +492,8 @@ photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable *ne
GObject *object;
const gchar *id;
+ g_return_if_fail (PHOTOS_IS_BASE_MANAGER (self));
+
old_objects = photos_base_manager_get_objects (self);
g_hash_table_iter_init (&iter, old_objects);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]