gio: Update GMemoryOutputStream length after truncate

For GMemoryOutputStream, update valid_len when truncating so that
g_memory_output_stream_get_data_size () returns the correct result.

https://bugzilla.gnome.org/show_bug.cgi?id=720080
This commit is contained in:
Ross Lagerwall 2013-12-08 22:41:15 +02:00 committed by Matthias Clasen
parent c34cc2348c
commit 3b9ad6e6ef
2 changed files with 7 additions and 0 deletions

View File

@ -828,6 +828,8 @@ g_memory_output_stream_truncate (GSeekable *seekable,
if (!array_resize (ostream, offset, FALSE, error)) if (!array_resize (ostream, offset, FALSE, error))
return FALSE; return FALSE;
ostream->priv->valid_len = offset;
return TRUE; return TRUE;
} }

View File

@ -50,6 +50,11 @@ test_truncate (void)
g_assert_no_error (error); g_assert_no_error (error);
} }
g_test_bug ("720080");
g_seekable_truncate (G_SEEKABLE (mo), 8192, NULL, &error);
g_assert_cmpint (g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (mo)), ==, 8192);
g_object_unref (o); g_object_unref (o);
g_object_unref (mo); g_object_unref (mo);
} }