Changeset 3585

Show
Ignore:
Timestamp:
04/15/08 10:30:20
Author:
djcb
Message:

* added more debugging code to nail the evil bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libtinymail-maemo/tny-maemo-conic-device.c

    r3581 r3585  
    112112        g_debug ("%s: destroying status info (%p)", __FUNCTION__, user_data); 
    113113 
    114         if (G_IS_OBJECT(info->self)) 
     114        if (G_IS_OBJECT(info->self)) { 
    115115                g_object_unref (info->self); 
    116          
    117         g_slice_free (EmitStatusInfo, info); 
    118  
    119         g_debug ("%s: destroyed %p", __FUNCTION__, user_data); 
     116               g_slice_free (EmitStatusInfo, info); 
     117               g_debug ("%s: destroyed %p", __FUNCTION__, user_data); 
     118        } else 
     119               g_warning ("%s: BUG: not a valid info", __FUNCTION__); 
    120120} 
    121121 
     
    210210                        g_error_free (err); 
    211211 
    212                 g_object_unref (info->self); 
    213                 g_free (info->iap_id); 
    214                 g_slice_free (ConnectInfo, info); 
     212                if (G_IS_OBJECT(info->self)) { 
     213                        g_object_unref (info->self); 
     214                        g_free (info->iap_id); 
     215                        info->iap_id = NULL; 
     216                        g_slice_free (ConnectInfo, info); 
     217                } else 
     218                        g_warning ("%s: BUG: info seems b0rked", __FUNCTION__); 
    215219        } 
    216220} 
     
    244248        info = (HandleConnInfo *) data; 
    245249 
    246         if (G_IS_OBJECT(info->self)) 
     250        if (G_IS_OBJECT(info->self)) { 
    247251                g_object_unref (info->self); 
    248          
    249         g_slice_free (HandleConnInfo, data);  
     252                g_slice_free (HandleConnInfo, data); 
     253        } else 
     254                g_warning ("%s: BUG: data seems b0rked", __FUNCTION__); 
    250255} 
    251256 
     
    332337        } 
    333338 
    334         if (emit) 
     339        if (emit) { 
     340                g_debug ("%s: emiting is_online (%s)", 
     341                         __FUNCTION__, is_online ? "true" : "false"); 
    335342                conic_emit_status (TNY_DEVICE (device), is_online); 
     343        } 
    336344} 
    337345 
    338346 
    339347/** 
    340  * tny_maemo_conic_device_connect
     348 * tny_maemo_conic_device_connect_async
    341349 * @self: a #TnyDevice object 
    342350 * @iap_id: the id of the Internet Access Point (IAP), or NULL for 'any; 
     
    397405        if (request_failed) { 
    398406                priv->connect_slot = NULL; 
    399                 if (info->callback) 
    400                         info->callback (info->self, iap_id, FALSE, err, info->user_data); 
    401                 g_free (info->iap_id); 
    402                 g_object_unref (info->self); 
    403                 g_slice_free (ConnectInfo, info); 
     407                if (G_IS_OBJECT(info->self)) { 
     408                        if (info->callback) 
     409                                info->callback (info->self, iap_id, FALSE, err, info->user_data); 
     410                        g_free (info->iap_id); 
     411                        info->iap_id = NULL; 
     412                        g_object_unref (info->self); 
     413                        info->self = NULL; 
     414                        g_slice_free (ConnectInfo, info); 
     415                } else  
     416                        g_warning ("%s: BUG: info seems b0rked", __FUNCTION__); 
    404417        } 
    405418} 
     
    521534} 
    522535 
     536static void 
     537unref_gobject (GObject *obj) 
     538{ 
     539        if (G_IS_OBJECT(obj)) 
     540                g_object_unref(obj); 
     541        else 
     542                g_warning ("%s: not a valid GObject (%p)", 
     543                           __FUNCTION__, obj); 
     544} 
     545 
    523546 
    524547/** 
     
    532555tny_maemo_conic_device_free_iap_list (TnyMaemoConicDevice *self, GSList* cnx_list) 
    533556{ 
    534         g_slist_foreach (cnx_list, (GFunc)g_object_unref, NULL); 
     557        g_slist_foreach (cnx_list, (GFunc)unref_gobject, NULL); 
    535558        g_slist_free (cnx_list); 
    536559} 
     
    555578 
    556579        /* Signal if it changed: */ 
    557         if (!already_online) 
     580        if (!already_online) { 
     581                g_debug ("%s: emiting connection-changed signal", 
     582                         __FUNCTION__); 
    558583                g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 0, TRUE); 
     584        } 
    559585} 
    560586 
     
    598624        /* We should not have a real is_online, based on what libconic has told us: */ 
    599625 
    600         priv->forced = FALSE; 
    601         priv->iap = NULL; 
    602         priv->is_online = FALSE; 
     626        priv->forced       = FALSE; 
     627        priv->iap          = NULL; 
     628        priv->is_online    = FALSE; 
    603629        priv->connect_slot = NULL; 
    604630 
     
    621647        /* This will get us in connected state only if there is already a connection. 
    622648         * thus, this will setup our state correctly when we receive the signals. */ 
    623         if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED)) 
     649        if (!con_ic_connection_connect (priv->cnx,  
     650                                        CON_IC_CONNECT_FLAG_AUTOMATICALLY_TRIGGERED)) 
    624651                g_warning ("%s: could not send connect dbus message", 
    625652                        __FUNCTION__);   
     
    643670        TnyMaemoConicDevicePriv *priv; 
    644671 
    645         g_return_if_fail (obj && G_IS_OBJECT(obj)); 
    646  
    647         g_debug ("%s", __FUNCTION__); 
     672        g_return_if_fail (TNY_IS_MAEMO_CONIC_DEVICE(obj)); 
     673 
     674        g_debug ("%s: shutting the device down...", __FUNCTION__); 
    648675         
    649676        priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (obj); 
     
    657684                g_object_unref (priv->cnx); 
    658685                priv->cnx = NULL; 
    659         } 
    660  
    661         if (priv->iap) { 
    662                g_free (priv->iap); 
    663                priv->iap = NULL
    664         } 
     686        } else 
     687                g_warning ("%s: BUG: priv->cnx is not a valid connection", 
     688                          __FUNCTION__); 
     689         
     690        g_free (priv->iap)
     691        priv->iap = NULL; 
    665692 
    666693        (*parent_class->finalize) (obj); 
     
    763790        ConIcConnectFlags flags; 
    764791 
     792        g_warning ("%s: you should tny_maemo_conic_device_connect_async", 
     793                   __FUNCTION__); 
     794 
    765795        g_return_val_if_fail (TNY_IS_DEVICE(self), FALSE); 
    766796        priv = TNY_MAEMO_CONIC_DEVICE_GET_PRIVATE (self); 
     
    788818 
    789819        if (request_failed) { 
    790                 g_object_unref (priv->loop); 
     820                g_main_loop_unref (priv->loop); 
    791821                priv->loop = NULL; 
    792822        } 
     
    802832        GDK_THREADS_ENTER(); 
    803833 
    804         g_main_loop_unref (priv->loop); 
    805         priv->loop = NULL; 
     834        if (priv->loop) { 
     835                g_main_loop_unref (priv->loop); 
     836                priv->loop = NULL; 
     837        } 
    806838 
    807839        return priv->is_online;