[libgdata] [general] Remove unnecessary g_object_notify() calls
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdata] [general] Remove unnecessary g_object_notify() calls
- Date: Mon, 25 Jan 2010 15:44:15 +0000 (UTC)
commit 8314ebcd5a4826aba1c1bc2e1c2f4c43afa40a33
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jan 25 15:42:54 2010 +0000
[general] Remove unnecessary g_object_notify() calls
There's no need to notify of property changes during XML parsing, as the
initial object state received from the server should be consistent. If it
isn't, it's either a bug at Google's end, or a new addition to the API which
libgdata shouldn't preempt.
gdata/gd/gdata-gd-name.c | 1 -
gdata/gdata-entry.c | 6 ++----
gdata/services/calendar/gdata-calendar-event.c | 4 ----
gdata/services/contacts/gdata-contacts-contact.c | 2 --
gdata/services/youtube/gdata-youtube-query.c | 6 ++----
gdata/services/youtube/gdata-youtube-video.c | 17 ++---------------
6 files changed, 6 insertions(+), 30 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
index d61ccc1..8ba43d8 100644
--- a/gdata/gd/gdata-gd-name.c
+++ b/gdata/gd/gdata-gd-name.c
@@ -295,7 +295,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (priv->full_name != NULL)
return gdata_parser_error_duplicate_element (node, error);
priv->full_name = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
- g_object_notify (G_OBJECT (parsable), "full-name"); /* various classes listen to this */
} else if (GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index fe60668..300fe30 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -324,8 +324,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
xmlChar *title = xmlNodeListGetString (doc, node->children, TRUE);
/* Title can be empty */
- self->priv->title = (title == NULL) ? g_strdup ("") : (gchar*) title;
- g_object_notify (G_OBJECT (self), "title"); /* various classes depend on updates to our title */
+ self->priv->title = (title != NULL) ? (gchar*) title : g_strdup ("");
} else if (xmlStrcmp (node->name, (xmlChar*) "id") == 0) {
/* atom:id */
g_free (self->priv->id);
@@ -384,11 +383,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
} else if (xmlStrcmp (node->name, (xmlChar*) "summary") == 0) {
/* atom:summary */
self->priv->summary = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
- g_object_notify (G_OBJECT (self), "summary"); /* various classes depend on updates to our title */
} else if (xmlStrcmp (node->name, (xmlChar*) "rights") == 0) {
/* atom:rights */
self->priv->rights = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
- g_object_notify (G_OBJECT (self), "rights"); /* various classes depend on updates to our title */
} else if (GDATA_PARSABLE_CLASS (gdata_entry_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
@@ -517,6 +514,7 @@ void
gdata_entry_set_title (GDataEntry *self, const gchar *title)
{
g_return_if_fail (GDATA_IS_ENTRY (self));
+
g_free (self->priv->title);
self->priv->title = g_strdup (title);
g_object_notify (G_OBJECT (self), "title");
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 0262cfa..c1834a5 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -582,12 +582,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
self->priv->recurrence = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
} else if (xmlStrcmp (node->name, (xmlChar*) "originalEvent") == 0) {
/* gd:originalEvent */
- g_object_freeze_notify (G_OBJECT (self));
self->priv->original_event_id = (gchar*) xmlGetProp (node, (xmlChar*) "id");
- g_object_notify (G_OBJECT (self), "original-event-id");
self->priv->original_event_uri = (gchar*) xmlGetProp (node, (xmlChar*) "href");
- g_object_notify (G_OBJECT (self), "original-event-uri");
- g_object_thaw_notify (G_OBJECT (self));
} else if (GDATA_PARSABLE_CLASS (gdata_calendar_event_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c
index ba5c4f7..a6d9bfc 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -285,14 +285,12 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
} else if (xmlStrcmp (node->name, (xmlChar*) "name") == 0) {
/* gd:name */
GDataGDName *name = GDATA_GD_NAME (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_NAME, doc, node, NULL, error));
-
if (name == NULL)
return FALSE;
if (self->priv->name != NULL)
g_object_unref (self->priv->name);
self->priv->name = name;
- g_object_notify (G_OBJECT (self), "name");
} else if (xmlStrcmp (node->name, (xmlChar*) "email") == 0) {
/* gd:email */
GDataGDEmailAddress *email = GDATA_GD_EMAIL_ADDRESS (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_EMAIL_ADDRESS, doc,
diff --git a/gdata/services/youtube/gdata-youtube-query.c b/gdata/services/youtube/gdata-youtube-query.c
index dc27729..787b65d 100644
--- a/gdata/services/youtube/gdata-youtube-query.c
+++ b/gdata/services/youtube/gdata-youtube-query.c
@@ -378,19 +378,15 @@ gdata_youtube_query_set_property (GObject *object, guint property_id, const GVal
break;
case PROP_LATITUDE:
self->priv->latitude = g_value_get_double (value);
- g_object_notify (object, "latitude");
break;
case PROP_LONGITUDE:
self->priv->longitude = g_value_get_double (value);
- g_object_notify (object, "longitude");
break;
case PROP_LOCATION_RADIUS:
self->priv->location_radius = g_value_get_double (value);
- g_object_notify (object, "location-radius");
break;
case PROP_HAS_LOCATION:
self->priv->has_location = g_value_get_boolean (value);
- g_object_notify (object, "has-location");
break;
case PROP_LANGUAGE:
gdata_youtube_query_set_language (self, g_value_get_string (value));
@@ -611,10 +607,12 @@ gdata_youtube_query_set_location (GDataYouTubeQuery *self, gdouble latitude, gdo
self->priv->location_radius = radius;
self->priv->has_location = has_location;
+ g_object_freeze_notify (G_OBJECT (self));
g_object_notify (G_OBJECT (self), "latitude");
g_object_notify (G_OBJECT (self), "longitude");
g_object_notify (G_OBJECT (self), "location-radius");
g_object_notify (G_OBJECT (self), "has-location");
+ g_object_thaw_notify (G_OBJECT (self));
}
/**
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index 2896133..f89a4a6 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -692,13 +692,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
self->priv->rating.max = strtoul ((gchar*) max, NULL, 10);
self->priv->rating.count = num_raters_uint;
self->priv->rating.average = average_double;
-
- g_object_freeze_notify (G_OBJECT (self));
- g_object_notify (G_OBJECT (self), "min-rating");
- g_object_notify (G_OBJECT (self), "max-rating");
- g_object_notify (G_OBJECT (self), "rating-count");
- g_object_notify (G_OBJECT (self), "average-rating");
- g_object_thaw_notify (G_OBJECT (self));
} else if (xmlStrcmp (node->name, (xmlChar*) "comments") == 0) {
/* gd:comments */
xmlChar *rel, *href, *count_hint, *read_only;
@@ -722,8 +715,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
/* TODO */
/*gdata_gd_feed_link_free (self->priv->comments_feed_link);
self->priv->comments_feed_link = gdata_gd_feed_link_new ((gchar*) href, (gchar*) rel, count_hint_uint,
- ((xmlStrcmp (read_only, (xmlChar*) "true") == 0) ? TRUE : FALSE));
- g_object_notify (G_OBJECT (self), "comments-feed-link");*/
+ ((xmlStrcmp (read_only, (xmlChar*) "true") == 0) ? TRUE : FALSE));*/
xmlFree (rel);
xmlFree (href);
@@ -737,16 +729,11 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
if (view_count == NULL)
return gdata_parser_error_required_property_missing (node, "viewCount", error);
self->priv->view_count = strtoul ((gchar*) view_count, NULL, 10);
- g_object_notify (G_OBJECT (self), "view-count");
xmlFree (view_count);
/* Favourite count */
favorite_count = xmlGetProp (node, (xmlChar*) "favoriteCount");
- if (favorite_count == NULL)
- self->priv->favorite_count = 0;
- else
- self->priv->favorite_count = strtoul ((gchar*) favorite_count, NULL, 10);
- g_object_notify (G_OBJECT (self), "favorite-count");
+ self->priv->favorite_count = (favorite_count != NULL) ? strtoul ((gchar*) favorite_count, NULL, 10) : 0;
xmlFree (favorite_count);
} else if (xmlStrcmp (node->name, (xmlChar*) "location") == 0) {
/* yt:location */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]