Comment 7 for bug 979959

Revision history for this message
TJ (tj) wrote :

libgnome-desktop/gnome-rr.c::gnome_rr_screen_new() says:

 * Returns: a unique #GnomeRRScreen instance, specific to the @screen, or NULL
 * if this could not be created, for instance if the driver does not support
 * Xrandr 1.2. Each #GdkScreen thus has a single instance of #GnomeRRScreen.

therefore in gnome-control-center panels/display/cc-diaply-panel.c::cc_display_panel_constructor() the following code is incorrect:

  self->priv->screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
  g_signal_connect (self->priv->screen, "changed", G_CALLBACK (on_screen_changed), self);
  if (!self->priv->screen)
    {
      error_message (NULL, _("Could not get screen information"), error->message);
      g_error_free (error);

if the call to gnome_rr_screen_new() returns NULL, as it will if no RANDR is available, the subsequent setup of the signal:

g_signal_connect (self->priv->screen, "changed", G_CALLBACK (on_screen_changed), self);

is done with self->priv->screen == NULL

So when that signal fires it passes a NULL screen pointer to on_screen_changed(). Passing the NULL pointer doesn't matter since it isn't used in the call-back, but self->priv->screen is used:

on_screen_changed (GnomeRRScreen *scr,
                   gpointer data)
{
  GnomeRRConfig *current;
  CcDisplayPanel *self = data;

  current = gnome_rr_config_new_current (self->priv->screen, NULL);
  gnome_rr_config_ensure_primary (current);

So current will be NULL after calling gnome_rr_config_new_current()