[Xfce4-commits] [xfce/xfce4-settings] 03/04: Avoid Segfault on reconnect scenario

noreply at xfce.org noreply at xfce.org
Sun Mar 11 13:31:24 CET 2018


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-settings.

commit 01ea721132a1bc2778267e5c2a6f88711b48b72f
Author: Florian Schüller <florian.schueller at gmail.com>
Date:   Sun Mar 4 00:04:16 2018 +0100

    Avoid Segfault on reconnect scenario
    
    I can reproduce a segfault with:
     * Connect a monitor (Monitors "overlap" now)
     * Select mirror mode * Apply * Disconnect monitor
     * Connect monitor again
---
 dialogs/display-settings/main.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 67d4577..cb1bf4f 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -179,14 +179,15 @@ static XfceOutputInfo*
 get_nth_xfce_output_info(gint id)
 {
     XfceOutputInfo *output = NULL;
+    GList * entry = NULL;
 
     if (current_outputs)
-        output = g_list_nth (current_outputs, id)->data;
+        entry = g_list_nth (current_outputs, id);
 
-    if (output)
-        return output;
+    if (entry)
+        output = entry->data;
 
-    return NULL;
+    return output;
 }
 
 static void
@@ -932,12 +933,14 @@ display_setting_mirror_displays_toggled (GtkToggleButton *togglebutton,
     for (n = 0; n < xfce_randr->noutput; n++)
     {
         output = get_nth_xfce_output_info (n);
-        output->rotation = xfce_randr->rotation[n];
-        output->x = xfce_randr->position[n].x;
-        output->y = xfce_randr->position[n].y;
-        output->mirrored = xfce_randr->mirrored[n];
-        output->width = xfce_randr_mode_width (xfce_randr_find_mode_by_id (xfce_randr, n, xfce_randr->mode[n]), 0);
-        output->height = xfce_randr_mode_height (xfce_randr_find_mode_by_id (xfce_randr, n, xfce_randr->mode[n]), 0);
+        if (output) {
+            output->rotation = xfce_randr->rotation[n];
+            output->x = xfce_randr->position[n].x;
+            output->y = xfce_randr->position[n].y;
+            output->mirrored = xfce_randr->mirrored[n];
+            output->width = xfce_randr_mode_width (xfce_randr_find_mode_by_id (xfce_randr, n, xfce_randr->mode[n]), 0);
+            output->height = xfce_randr_mode_height (xfce_randr_find_mode_by_id (xfce_randr, n, xfce_randr->mode[n]), 0);
+        } /* else: some kind of racecondition during re-connect? - just ignore */
     }
 
     /* Apply the changes */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list