virtual-image: Also unref the object when closing a the stream
While a stream is closed when completely unreffed, the other way around isn't true, so always unref the object.
This commit is contained in:
parent
8c05f3b78c
commit
5927a205e3
1 changed files with 5 additions and 4 deletions
|
@ -81,7 +81,7 @@ recv_image_img_recv_cb (GObject *source_object,
|
||||||
|
|
||||||
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
|
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
|
||||||
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
||||||
self->connection = NULL;
|
g_clear_object (&self->connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ recv_image_hdr_recv_cb (GObject *source_object,
|
||||||
|
|
||||||
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
|
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
|
||||||
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
||||||
self->connection = NULL;
|
g_clear_object (&self->connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ recv_image_hdr_recv_cb (GObject *source_object,
|
||||||
{
|
{
|
||||||
g_warning ("Image header suggests an unrealistically large image, disconnecting client.");
|
g_warning ("Image header suggests an unrealistically large image, disconnecting client.");
|
||||||
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
||||||
self->connection = NULL;
|
g_clear_object (&self->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->recv_img_hdr[0] < 0 || self->recv_img_hdr[1] < 0)
|
if (self->recv_img_hdr[0] < 0 || self->recv_img_hdr[1] < 0)
|
||||||
|
@ -148,7 +148,7 @@ recv_image_hdr_recv_cb (GObject *source_object,
|
||||||
default:
|
default:
|
||||||
/* disconnect client, it didn't play fair */
|
/* disconnect client, it didn't play fair */
|
||||||
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
|
||||||
self->connection = NULL;
|
g_clear_object (&self->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And, listen for more images from the same client. */
|
/* And, listen for more images from the same client. */
|
||||||
|
@ -206,6 +206,7 @@ new_connection_cb (GObject *source_object, GAsyncResult *res, gpointer user_data
|
||||||
if (dev->connection)
|
if (dev->connection)
|
||||||
{
|
{
|
||||||
g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
|
g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
|
||||||
|
g_object_unref (connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue