[gnome-flashback] display-config: be more robust when reading XRROutputInfos
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] display-config: be more robust when reading XRROutputInfos
- Date: Sun, 29 Nov 2015 19:48:14 +0000 (UTC)
commit dbe7e7f083fd3d44215af5d96bdee388b7cb7ee7
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Oct 15 19:34:40 2015 +0200
display-config: be more robust when reading XRROutputInfos
We might get modes in XRROutputInfos that aren't in the
XRRScreenResources we get earlier. This always seems to be transient,
i.e. when it happens, the X server will usually send us a follow up
RRScreenChangeNotify where we then get a "stable" view of the world
again.
In any case, when these glitches happen, we end up with NULL pointers
in the MetaOutput->modes array which makes us crash later on. This
patch ensures that doesn't happen.
https://bugzilla.gnome.org/show_bug.cgi?id=756660
.../libdisplay-config/flashback-monitor-manager.c | 44 +++++++++++++-------
1 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
b/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
index 92f42e0..abdf346 100644
--- a/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
+++ b/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
@@ -785,6 +785,32 @@ compare_outputs (const void *one,
return strcmp (o_one->name, o_two->name);
}
+static void
+output_get_modes (FlashbackMonitorManager *manager,
+ MetaOutput *meta_output,
+ XRROutputInfo *output)
+{
+ guint j, k;
+ guint n_actual_modes;
+
+ meta_output->modes = g_new0 (MetaMonitorMode *, output->nmode);
+
+ n_actual_modes = 0;
+ for (j = 0; j < (guint)output->nmode; j++)
+ {
+ for (k = 0; k < manager->n_modes; k++)
+ {
+ if (output->modes[j] == (XID)manager->modes[k].mode_id)
+ {
+ meta_output->modes[n_actual_modes] = &manager->modes[k];
+ n_actual_modes += 1;
+ break;
+ }
+ }
+ }
+ meta_output->n_modes = n_actual_modes;
+}
+
static char *
get_xmode_name (XRRModeInfo *xmode)
{
@@ -1255,6 +1281,8 @@ read_current_config (FlashbackMonitorManager *manager)
MetaOutput *meta_output;
output = XRRGetOutputInfo (priv->xdisplay, resources, resources->outputs[i]);
+ if (!output)
+ continue;
meta_output = &manager->outputs[n_actual_outputs];
@@ -1277,21 +1305,7 @@ read_current_config (FlashbackMonitorManager *manager)
meta_output->connector_type = output_get_connector_type (priv, meta_output);
output_get_tile_info (priv, meta_output);
-
- meta_output->n_modes = output->nmode;
- meta_output->modes = g_new0 (MetaMonitorMode *, meta_output->n_modes);
-
- for (j = 0; j < meta_output->n_modes; j++)
- {
- for (k = 0; k < manager->n_modes; k++)
- {
- if (output->modes[j] == (XID)manager->modes[k].mode_id)
- {
- meta_output->modes[j] = &manager->modes[k];
- break;
- }
- }
- }
+ output_get_modes (manager, meta_output, output);
meta_output->preferred_mode = meta_output->modes[0];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]