tags 445310 +patch thanks
Here's a patch against 0.1-2 that fixes this crash, and fixes a bunch of build warnings. There are still some left and not everything is done correctly, but this should make it easier to find them. The only important change is the first block of callbacks.c, which fixes this associated bug.
reverted: --- grandr-0.1/src/grandr.h +++ grandr-0.1.orig/src/grandr.h @@ -28,7 +28,7 @@ #include "constant.h" +struct SceenInfo; -struct ScreenInfo; struct CrtcInfo { RRCrtc id; @@ -42,7 +42,7 @@ int changed; + struct SceenInfo *screen_info; - struct ScreenInfo *screen_info; }; struct OutputInfo { @@ -83,7 +83,7 @@ extern GtkListStore *center_store, *left_store, *right_store, *above_store, *below_store; extern GtkListStore *mode_store; extern const guint8 big_pixbuf[], small_pixbuf[]; + -void free_screen_info (struct ScreenInfo *screen_info); GdkPixbuf* randr_create_pixbuf (const guint8 *data); struct ScreenInfo* read_screen_info (Display *); reverted: --- grandr-0.1/src/callbacks.c +++ grandr-0.1.orig/src/callbacks.c @@ -155,14 +155,12 @@ on_modes_combo_changed (GtkComboBox *combobox, gpointer user_data) { + GtkTreeModel *model; GtkTreeIter iter; - GtkTreeModel *model; int mode_id; - if (!gtk_combo_box_get_active_iter (combobox, &iter)) - return; model = gtk_combo_box_get_model (combobox); + gtk_combo_box_get_active_iter (combobox, &iter); - gtk_tree_model_get (model, &iter, COL_MODE_ID, &mode_id, -1); @@ -233,7 +231,7 @@ GtkTreeIter iter; GList *path_list; GtkTreePath *tree_path; + int output_id; - static int output_id; int i; GtkIconView *iconview = (GtkIconView *) widget; @@ -263,7 +261,7 @@ &output_id, sizeof (int) ); + gtk_list_store_remove (model, &iter); - gtk_list_store_remove (GTK_LIST_STORE(model), &iter); } @@ -291,9 +289,9 @@ output_id = (int) *data->data; output_name = get_output_name (screen_info, output_id); + store = gtk_icon_view_get_model (widget); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, - store = gtk_icon_view_get_model (GTK_ICON_VIEW(widget)); - gtk_list_store_append (GTK_LIST_STORE(store), &iter); - gtk_list_store_set (GTK_LIST_STORE(store), &iter, COL_OUTPUT_ID, output_id, COL_OUTPUT_NAME, output_name, COL_OUTPUT_PIXBUF, output_pixbuf, @@ -313,7 +311,7 @@ if (gtk_toggle_button_get_active (togglebutton)) { gtk_widget_set_sensitive (mode_combo, FALSE); + gtk_toggle_button_set_active (off_cbtn, FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(off_cbtn), FALSE); screen_info->cur_output->auto_set = 1; screen_info->cur_output->off_set = 0; @@ -322,7 +320,7 @@ //screen_info->cur_crtc->changed = 1; } else { + if (!gtk_toggle_button_get_active (off_cbtn)) { - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(off_cbtn))) { gtk_widget_set_sensitive (mode_combo, TRUE); } } @@ -341,7 +339,7 @@ if (gtk_toggle_button_get_active (togglebutton)) { gtk_widget_set_sensitive (mode_combo, FALSE); + gtk_toggle_button_set_active (auto_cbtn, FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(auto_cbtn), FALSE); screen_info->cur_output->auto_set = 0; screen_info->cur_output->off_set = 1; @@ -350,7 +348,7 @@ //screen_info->cur_crtc->changed = 1; } else { + if (!gtk_toggle_button_get_active (auto_cbtn)) { - if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(auto_cbtn))) { gtk_widget_set_sensitive (mode_combo, TRUE); } } @@ -391,8 +389,8 @@ along with RandR GUI; if not, write to the Free Software Foundation, Inc.,\n \ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"; + gtk_show_about_dialog (root_window, + "authors", authors, - gtk_show_about_dialog (GTK_WINDOW(root_window), - "authors", authors, "comments", comments, "name", "RandR GUI", "license", license, diff -u grandr-0.1/src/grandr.c grandr-0.1/src/grandr.c --- grandr-0.1/src/grandr.c +++ grandr-0.1/src/grandr.c @@ -23,7 +23,6 @@ #include "support.h" #include "callbacks.h" #include <stdlib.h> -#include <string.h> #include <gconf/gconf-client.h> static Status crtc_disable (struct CrtcInfo *crtc); @@ -33,7 +32,7 @@ char * get_output_name (struct ScreenInfo *screen_info, RROutput id) { - char *output_name = NULL; + char *output_name; int i; for (i = 0; i < screen_info->n_output; i++) { @@ -52,7 +51,7 @@ XRRModeInfo * find_mode_by_xid (struct ScreenInfo *screen_info, RRMode mode_id) { - XRRModeInfo *mode_info = NULL; + XRRModeInfo *mode_info; XRRScreenResources *res; int i; @@ -214,8 +213,8 @@ int screen; struct CrtcInfo *crtc; XRRModeInfo *mode_info; - int cur_x = 0, cur_y = 0; - int w = 0, h = 0; + int cur_x, cur_y; + int w, h; int mmW, mmH; int max_width = 0, max_height = 0; int i; @@ -406,7 +405,7 @@ set_positions (screen_info); if (!set_screen_size (screen_info)) { - dialog = gtk_message_dialog_new (GTK_WINDOW(root_window), + dialog = gtk_message_dialog_new (root_window, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CANCEL, @@ -651,14 +650,16 @@ } -static gchar * +static char * get_mode_name (struct ScreenInfo *screen_info, RRMode mode_id) { XRRScreenResources *sr; - gchar *mode_name = NULL; + char *mode_name; + int mode_name_len = 40; int i; sr = screen_info->res; + mode_name = malloc (mode_name_len); for (i = 0; i < sr->nmode; i++) { if (sr->modes[i].id == mode_id) { @@ -667,16 +668,16 @@ } if (i == sr->nmode) { - mode_name = g_strdup ("Unknown mode"); + snprintf (mode_name, mode_name_len, "%s", "Unknown mode"); } else { double rate; if (sr->modes[i].hTotal && sr->modes[i].vTotal) { rate = ((double) sr->modes[i].dotClock / ((double) sr->modes[i].hTotal * (double) sr->modes[i].vTotal)); - } else { + } else { rate = 0; } - mode_name = g_strdup_printf ("%s%6.1fHz", sr->modes[i].name, rate); + snprintf (mode_name, mode_name_len, "%s%6.1fHz", sr->modes[i].name, rate); } return mode_name; @@ -729,7 +730,7 @@ GtkTreeIter iter; XRROutputInfo *output_info; - gchar *mode_name; + char *mode_name; int i; int mode_index = -1; @@ -749,7 +750,7 @@ COL_MODE_NAME, mode_name, -1); mode_index++; - g_free (mode_name); + free (mode_name); if (output->cur_crtc && output->cur_crtc->cur_mode_id == output_info->modes[i]) { active_num = mode_index; @@ -1189,7 +1190,7 @@ GtkWidget *pos_iview[N_POSITIONS]; struct CrtcInfo *crtc_info; RRCrtc *crtc_list; - int list_len = 0; + int list_len; int x, y; int center_x, right_x; int center_y, below_y;