[gnome-flashback] display-config: skip outputs with no crtcs
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] display-config: skip outputs with no crtcs
- Date: Sun, 29 Nov 2015 19:48:29 +0000 (UTC)
commit b72e79dbb642f892bc436cf8a28093d7a7967ed2
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Oct 27 15:43:58 2015 +0100
display-config: skip outputs with no crtcs
Outputs with no crtcs shouldn't happen, but if it does we should
ignore them, instead of possibly crashing later.
https://bugzilla.gnome.org/show_bug.cgi?id=756796
.../libdisplay-config/flashback-monitor-manager.c | 66 ++++++++++++--------
1 files changed, 39 insertions(+), 27 deletions(-)
---
diff --git a/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
b/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
index b2e12b6..8812dbd 100644
--- a/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
+++ b/gnome-flashback/libdisplay-config/flashback-monitor-manager.c
@@ -813,6 +813,43 @@ output_get_modes (FlashbackMonitorManager *manager,
meta_output->preferred_mode = meta_output->modes[0];
}
+static void
+output_get_crtcs (FlashbackMonitorManager *manager,
+ MetaOutput *meta_output,
+ XRROutputInfo *output)
+{
+ guint j, k;
+ guint n_actual_crtcs;
+
+ meta_output->possible_crtcs = g_new0 (MetaCRTC *, output->ncrtc);
+
+ n_actual_crtcs = 0;
+ for (j = 0; j < (unsigned)output->ncrtc; j++)
+ {
+ for (k = 0; k < manager->n_crtcs; k++)
+ {
+ if ((XID)manager->crtcs[k].crtc_id == output->crtcs[j])
+ {
+ meta_output->possible_crtcs[n_actual_crtcs] = &manager->crtcs[k];
+ n_actual_crtcs += 1;
+ break;
+ }
+ }
+ }
+
+ meta_output->n_possible_crtcs = n_actual_crtcs;
+
+ meta_output->crtc = NULL;
+ for (j = 0; j < manager->n_crtcs; j++)
+ {
+ if ((XID)manager->crtcs[j].crtc_id == output->crtc)
+ {
+ meta_output->crtc = &manager->crtcs[j];
+ break;
+ }
+ }
+}
+
static char *
get_xmode_name (XRRModeInfo *xmode)
{
@@ -1338,32 +1375,7 @@ read_current_config (FlashbackMonitorManager *manager)
output_get_tile_info (priv, meta_output);
output_get_modes (manager, meta_output, output);
-
- meta_output->n_possible_crtcs = output->ncrtc;
- meta_output->possible_crtcs = g_new0 (MetaCRTC *, meta_output->n_possible_crtcs);
-
- for (j = 0; j < (unsigned)output->ncrtc; j++)
- {
- for (k = 0; k < manager->n_crtcs; k++)
- {
- if ((XID)manager->crtcs[k].crtc_id == output->crtcs[j])
- {
- meta_output->possible_crtcs[j] = &manager->crtcs[k];
- break;
- }
- }
- }
-
- meta_output->crtc = NULL;
-
- for (j = 0; j < manager->n_crtcs; j++)
- {
- if ((XID)manager->crtcs[j].crtc_id == output->crtc)
- {
- meta_output->crtc = &manager->crtcs[j];
- break;
- }
- }
+ output_get_crtcs (manager, meta_output, output);
meta_output->n_possible_clones = output->nclone;
meta_output->possible_clones = g_new0 (MetaOutput *, meta_output->n_possible_clones);
@@ -1387,7 +1399,7 @@ read_current_config (FlashbackMonitorManager *manager)
else
meta_output->backlight = -1;
- if (meta_output->n_modes == 0)
+ if (meta_output->n_modes == 0 || meta_output->n_possible_crtcs == 0)
clear_output (meta_output);
else
n_actual_outputs++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]