[gnome-desktop/randr-assignment-errors] Accumulate errors in the recursive real_assign_crtcs()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop/randr-assignment-errors] Accumulate errors in the recursive real_assign_crtcs()
- Date: Thu, 8 Apr 2010 18:43:19 +0000 (UTC)
commit adde41e2a4ee87f764150343cbfa39b2c59cb4e4
Author: Federico Mena Quintero <federico novell com>
Date: Thu Apr 8 13:35:28 2010 -0500
Accumulate errors in the recursive real_assign_crtcs()
When we need to debug why a CRTC assignment didn't succeed, we need the full
log of what the algorithm tried to do. This accumulates the errors that
happen along the process inside real_assign_crtcs(). Before we could
silently leak the innermost errors, and we were ignoring them in the end.
Signed-off-by: Federico Mena Quintero <federico novell com>
libgnome-desktop/gnome-rr-config.c | 90 +++++++++++++++++++++++++++++------
1 files changed, 74 insertions(+), 16 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index 85387ce..6db57dd 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -1427,11 +1427,11 @@ crtc_assignment_assign (CrtcAssignment *assign,
if (!gnome_rr_output_supports_mode (output, mode))
{
g_set_error (error, GNOME_RR_ERROR, GNOME_RR_ERROR_CRTC_ASSIGNMENT,
- _("output %s does not support mode %dx%d %fHz"),
+ _("output %s does not support mode %dx%d %dHz"),
output_name,
gnome_rr_mode_get_width (mode),
gnome_rr_mode_get_height (mode),
- gnome_rr_mode_get_freq (mode) / 1000000.0);
+ gnome_rr_mode_get_freq (mode));
return FALSE;
}
@@ -1587,6 +1587,13 @@ crtc_is_rotated (GnomeRRCrtc *crtc)
return FALSE;
}
+static void
+accumulate_error (GString *accumulated_error, GError *error)
+{
+ g_string_append_printf (accumulated_error, " %s\n", error->message);
+ g_error_free (error);
+}
+
/* Check whether the given set of settings can be used
* at the same time -- ie. whether there is an assignment
* of CRTC's to outputs.
@@ -1603,6 +1610,10 @@ real_assign_crtcs (GnomeRRScreen *screen,
GnomeRRCrtc **crtcs = gnome_rr_screen_list_crtcs (screen);
GnomeOutputInfo *output;
int i;
+ gboolean tried_mode;
+ GError *my_error;
+ GString *accumulated_error;
+ gboolean success;
output = *outputs;
if (!output)
@@ -1614,48 +1625,95 @@ real_assign_crtcs (GnomeRRScreen *screen,
return real_assign_crtcs (screen, outputs + 1, assignment, error);
}
+ success = FALSE;
+ tried_mode = FALSE;
+ accumulated_error = g_string_new (NULL);
+
for (i = 0; crtcs[i] != NULL; ++i)
{
int pass;
- /* Make two passses, one where frequencies must match, then
+ /* Make two passes, one where frequencies must match, then
* one where they don't have to
*/
for (pass = 0; pass < 2; ++pass)
{
GnomeRRCrtc *crtc = crtcs[i];
- GnomeRROutput *gnome_rr_output =
- gnome_rr_screen_get_output_by_name (screen, output->name);
+ int crtc_id = gnome_rr_crtc_get_id (crtc);
+ GnomeRROutput *gnome_rr_output = gnome_rr_screen_get_output_by_name (screen, output->name);
GnomeRRMode **modes = gnome_rr_output_list_modes (gnome_rr_output);
int j;
-
+
for (j = 0; modes[j] != NULL; ++j)
{
GnomeRRMode *mode = modes[j];
-
- if (gnome_rr_mode_get_width (mode) == output->width &&
- gnome_rr_mode_get_height (mode) == output->height &&
- (pass == 1 || gnome_rr_mode_get_freq (mode) == output->rate))
+ int mode_width;
+ int mode_height;
+ int mode_freq;
+
+ mode_width = gnome_rr_mode_get_width (mode);
+ mode_height = gnome_rr_mode_get_height (mode);
+ mode_freq = gnome_rr_mode_get_freq (mode);
+
+ g_string_append_printf (accumulated_error,
+ _("CRTC %d: trying mode %dx%d %dHz with output at %dx%d %dHz (pass %d)\n"),
+ crtc_id,
+ mode_width, mode_height, mode_freq,
+ output->width, output->height, output->rate,
+ pass);
+
+ if (mode_width == output->width &&
+ mode_height == output->height &&
+ (pass == 1 || mode_freq == output->rate))
{
+ tried_mode = TRUE;
+
+ my_error = NULL;
if (crtc_assignment_assign (
assignment, crtc, modes[j],
output->x, output->y,
output->rotation,
output->primary,
gnome_rr_output,
- error))
+ &my_error))
{
- if (real_assign_crtcs (screen, outputs + 1, assignment, error))
- return TRUE;
-
+ my_error = NULL;
+ if (real_assign_crtcs (screen, outputs + 1, assignment, &my_error)) {
+ success = TRUE;
+ goto out;
+ } else
+ accumulate_error (accumulated_error, my_error);
+
crtc_assignment_unassign (assignment, crtc, gnome_rr_output);
- }
+ } else
+ accumulate_error (accumulated_error, my_error);
}
}
}
}
- return FALSE;
+out:
+
+ if (success)
+ g_string_free (accumulated_error, TRUE);
+ else {
+ char *str;
+
+ str = g_string_free (accumulated_error, FALSE);
+
+ if (tried_mode)
+ g_set_error (error, GNOME_RR_ERROR, GNOME_RR_ERROR_CRTC_ASSIGNMENT,
+ _("could not assign CRTCs to outputs:\n%s"),
+ str);
+ else
+ g_set_error (error, GNOME_RR_ERROR, GNOME_RR_ERROR_CRTC_ASSIGNMENT,
+ _("none of the selected modes were compatible with the possible modes:\n%s"),
+ str);
+
+ g_free (str);
+ }
+
+ return success;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]