display: Prevent error when serializing invalid configuration

If no monitors are enabled, then the variant would end up with an
invalid variant type, causing a crash later on. This case only happened
due to other bugs (i.e. in principle we should never send a
configuration without any monitors to the server).

Prevent the serialization error by specifying the correct type for the
builder, therefore potentially preventing a crash in such a corner case.
This commit is contained in:
Benjamin Berg 2019-03-20 14:31:57 +01:00
parent 0c4e84e417
commit ae22f72cac

View file

@ -951,7 +951,7 @@ build_logical_monitors_parameter (CcDisplayConfigDBus *self)
GHashTableIter iter;
CcDisplayLogicalMonitor *logical_monitor;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(iiduba(ssa{sv}))"));
g_hash_table_iter_init (&iter, self->logical_monitors);
while (g_hash_table_iter_next (&iter, (void **) &logical_monitor, NULL))