[gnome-initial-setup] Fix a few issues where we chew too much from the start of the text file
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] Fix a few issues where we chew too much from the start of the text file
- Date: Thu, 31 May 2012 21:18:27 +0000 (UTC)
commit f94bb369b816df828a4af8c38b86d9334bbc7956
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu May 31 16:37:41 2012 -0400
Fix a few issues where we chew too much from the start of the text file
GDataInputStream is buffered, which means that we can't just read from
the original stream and expect it to work. Since GDataInputStream is
still a GInputStream, we can just splice it to a text buffer instead.
gnome-initial-setup/gdm-initial-setup.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/gnome-initial-setup/gdm-initial-setup.c b/gnome-initial-setup/gdm-initial-setup.c
index ec69337..0278beb 100644
--- a/gnome-initial-setup/gdm-initial-setup.c
+++ b/gnome-initial-setup/gdm-initial-setup.c
@@ -139,7 +139,7 @@ splice_buffer (GInputStream *stream,
break;
gtk_text_buffer_get_end_iter (buffer, &iter);
- gtk_text_buffer_insert (buffer, &iter, contents, sizeof (contents));
+ gtk_text_buffer_insert (buffer, &iter, contents, n_read);
}
}
@@ -147,8 +147,8 @@ static GtkWidget *
build_eula_text_view (GFile *eula,
char **title_out)
{
- GInputStream *input_stream;
- GDataInputStream *data_input_stream;
+ GInputStream *input_stream = NULL;
+ GDataInputStream *data_input_stream = NULL;
GError *error = NULL;
GtkWidget *widget = NULL;
GtkTextBuffer *buffer;
@@ -170,8 +170,7 @@ build_eula_text_view (GFile *eula,
}
buffer = gtk_text_buffer_new (NULL);
- g_object_unref (data_input_stream);
- splice_buffer (input_stream, buffer, &error);
+ splice_buffer (G_INPUT_STREAM (data_input_stream), buffer, &error);
if (error != NULL) {
g_printerr (error->message);
goto out;
@@ -180,8 +179,7 @@ build_eula_text_view (GFile *eula,
widget = gtk_text_view_new_with_buffer (buffer);
out:
- if (data_input_stream != NULL)
- g_object_unref (data_input_stream);
+ g_clear_object (&data_input_stream);
g_clear_error (&error);
return widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]