[gnome-settings-daemon] common: Fix initialization of GsdDeviceMapper



commit faff64c793b00c5651710afdf22b8c0394843de6
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 21 12:30:04 2014 +0100

    common: Fix initialization of GsdDeviceMapper
    
    Commit a73c5903ac introduced async GnomeRRScreen initialization but
    didn't cover all initialization scenarios. In the lowlevel functions,
    g_return_if_fail() is called if there is no GnomeRRScreen yet, and
    in the higher level functions, just check for it not being NULL. After
    the screen initialization, _device_mapper_update_outputs() will be
    called, which will catch up mapping every previously added input device.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726807

 plugins/common/gsd-device-mapper.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/plugins/common/gsd-device-mapper.c b/plugins/common/gsd-device-mapper.c
index 0a94e7b..418c5e2 100644
--- a/plugins/common/gsd-device-mapper.c
+++ b/plugins/common/gsd-device-mapper.c
@@ -188,9 +188,7 @@ find_output_by_edid (GnomeRRScreen *rr_screen,
        GnomeRROutput *retval = NULL;
        guint i;
 
-        /* possible during async initialization */
-       if (rr_screen == NULL)
-               return NULL;
+       g_return_val_if_fail (rr_screen != NULL, NULL);
 
        outputs = gnome_rr_screen_list_outputs (rr_screen);
 
@@ -230,6 +228,8 @@ find_builtin_output (GnomeRRScreen *rr_screen)
        GnomeRROutput **outputs;
        guint i;
 
+       g_return_val_if_fail (rr_screen != NULL, NULL);
+
        outputs = gnome_rr_screen_list_outputs (rr_screen);
 
        for (i = 0; outputs[i] != NULL; i++) {
@@ -250,6 +250,8 @@ monitor_to_output (GsdDeviceMapper *mapper,
        GnomeRROutput **outputs;
        guint i;
 
+       g_return_val_if_fail (mapper->rr_screen != NULL, NULL);
+
        outputs = gnome_rr_screen_list_outputs (mapper->rr_screen);
 
        for (i = 0; outputs[i] != NULL; i++) {
@@ -843,7 +845,7 @@ device_settings_changed_cb (GSettings        *settings,
                                                      rr_output);
                        input_info_set_output (input, output, FALSE, FALSE);
                        input_info_remap (input);
-               } else {
+               } else if (input->mapper->rr_screen) {
                        /* Guess an output for this device */
                        mapper_recalculate_input (input->mapper, input);
                }
@@ -883,7 +885,7 @@ input_info_new (GdkDevice   *device,
                                              rr_output);
                input_info_set_output (info, output, FALSE, FALSE);
                input_info_remap (info);
-       } else {
+       } else if (mapper->rr_screen) {
                mapper_recalculate_input (mapper, info);
        }
 
@@ -955,6 +957,9 @@ _device_mapper_update_outputs (GsdDeviceMapper *mapper)
        GHashTable *map;
        gint i = 0;
 
+       /* This *must* only be ever called after screen initialization */
+       g_assert (mapper->rr_screen != NULL);
+
        map = g_hash_table_new_full (NULL, NULL, NULL,
                                     (GDestroyNotify) output_info_free);
        outputs = gnome_rr_screen_list_outputs (mapper->rr_screen);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]