static gboolean vivs_net_inspiration_on_recv(GIOChannel *source, GIOCondition condition, gpointer data)
{
VivsNetInspiration* self = VIVS_NET_INSPIRATION(data);
if(!g_object_ref(self))
return FALSE;
g_mutex_lock(self->priv->lock);
gsize length = 0;
GError* err = NULL;
if(self->priv->channel && self->priv->composition)
{
GIOStatus status = g_io_channel_read_chars(self->priv->channel,
self->priv->pkt_buffer, MAX_PKT_LEN, &length, &err);
if(G_IO_STATUS_NORMAL == status)
{
// ??????????? the following line crash because self->priv->composition is NULL
// at this moment, which is almost impossible.
// composition could only be null after dispose, but I have called g_object_ref(self)
// How can this happen!!
vivs_icomposition_write(self->priv->composition, self->priv->pkt_buffer, length);
}
else if(G_IO_STATUS_AGAIN != status)
{
g_assert(err != NULL);
g_error_free(err);
}
-
}
on_return:
g_mutex_unlock(self->priv->lock);
g_object_unref(self);
return TRUE;
}