printjob: Clarify array ownership in gtk_print_job_set_page_ranges()

Add a documentation annotation saying that set_page_ranges transfers
ownership of the GtkPageRange array.
Add a g_free() call to fix a memory leak when set_page_ranges is
used repeatedly.

https://bugzilla.gnome.org/show_bug.cgi?id=780234
This commit is contained in:
Kjell Ahlstedt 2017-03-24 16:41:47 +01:00 committed by Daniel Boles
parent a7ca5335e4
commit c3d759c3b6

View File

@ -781,7 +781,7 @@ gtk_print_job_get_page_ranges (GtkPrintJob *job,
/**
* gtk_print_job_set_page_ranges:
* @job: a #GtkPrintJob
* @ranges: (array length=n_ranges): pointer to an array of
* @ranges: (array length=n_ranges) (transfer full): pointer to an array of
* #GtkPageRange structs
* @n_ranges: the length of the @ranges array
*
@ -794,6 +794,7 @@ gtk_print_job_set_page_ranges (GtkPrintJob *job,
GtkPageRange *ranges,
gint n_ranges)
{
g_free (job->priv->page_ranges);
job->priv->page_ranges = ranges;
job->priv->num_page_ranges = n_ranges;
}