printing: Be more careful when deserializing

The GVariant we are getting here might not be coming
from GTK+, but rather from some other source. Best to
be forgiving and deal with missing data without crashing.

This was causing the GTK+ portal backends to crash on
print requests from Qt.
This commit is contained in:
Matthias Clasen 2018-04-20 16:56:28 -04:00
parent ecc612b1a2
commit 21fddc3994

View File

@ -902,8 +902,11 @@ gtk_page_setup_new_from_gvariant (GVariant *variant)
setup = gtk_page_setup_new ();
paper_size = gtk_paper_size_new_from_gvariant (variant);
gtk_page_setup_set_paper_size (setup, paper_size);
gtk_paper_size_free (paper_size);
if (paper_size)
{
gtk_page_setup_set_paper_size (setup, paper_size);
gtk_paper_size_free (paper_size);
}
if (g_variant_lookup (variant, "MarginTop", "d", &margin))
gtk_page_setup_set_top_margin (setup, margin, GTK_UNIT_MM);