[gnome-initial-setup/shell/4765: 28/362] Use source object to get results



commit 26f6a3d68abd3373a3438f4af1bbfb1b48c1bf71
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Fri May 2 14:08:18 2014 +0200

    Use source object to get results
    
    If the operation is cancelled the value of "page" is invalid, so it is
    better not to rely on that for the finish() operation.
    
    Instead, use the object used in the callback.
    
    [endlessm/eos-shell#2401]

 .../pages/location/gis-location-page.c             |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/gnome-initial-setup/pages/location/gis-location-page.c 
b/gnome-initial-setup/pages/location/gis-location-page.c
index 4c26aef..f15c3ba 100644
--- a/gnome-initial-setup/pages/location/gis-location-page.c
+++ b/gnome-initial-setup/pages/location/gis-location-page.c
@@ -81,12 +81,10 @@ set_timezone_cb (GObject      *source,
                  GAsyncResult *res,
                  gpointer      user_data)
 {
-  GisLocationPage *page = user_data;
-  GisLocationPagePrivate *priv = gis_location_page_get_instance_private (page);
   GError *error;
 
   error = NULL;
-  if (!timedate1_call_set_timezone_finish (priv->dtm,
+  if (!timedate1_call_set_timezone_finish (TIMEDATE1 (source),
                                            res,
                                            &error)) {
     /* TODO: display any error in a user friendly way */
@@ -235,11 +233,9 @@ location_changed (GObject *object, GParamSpec *param, GisLocationPage *page)
 static void
 set_using_ntp_cb (GObject *object, GAsyncResult *res, gpointer user_data)
 {
-  GisLocationPage *page = user_data;
-  GisLocationPagePrivate *priv = gis_location_page_get_instance_private (page);
   GError *error = NULL;
 
-  if (!timedate1_call_set_ntp_finish (priv->dtm, res, &error))
+  if (!timedate1_call_set_ntp_finish (TIMEDATE1 (object), res, &error))
     {
       g_warning ("Could not set system to use NTP: %s", error->message);
       g_error_free (error);
@@ -346,10 +342,9 @@ static void
 set_time_cb (GObject *source, GAsyncResult *res, gpointer user_data)
 {
   GisLocationPage *page = user_data;
-  GisLocationPagePrivate *priv = gis_location_page_get_instance_private (page);
   GError *error = NULL;
 
-  if(!timedate1_call_set_time_finish (priv->dtm, res, &error))
+  if(!timedate1_call_set_time_finish (TIMEDATE1 (source), res, &error))
     {
       g_warning ("Could not set system time: %s", error->message);
       g_error_free (error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]