this always seems to happen, reorganize - now seg fault



This program seemed to be working perfectly then I decided to split it
into 3 pieces and now one function fails. Just for entertainment I tried
putting everything back into one file but the problem still occurs.

I've attached the one very small function... all it does is try to create
a window on which it will put a 480x480 image (created on the fly) and
then paste 40x40 images over it in a grid pattern.

This is where I suspect the problem is but it worked before I reorganized
so I don't know if it is actually wrong or not:

        /* Create the actual board */
        the_board = gdk_pixmap_new(
                        main_window->window, 480, 480, 16);
        /* Load up an element */
        new_element = gdk_pixmap_create_from_xpm_d(
                        main_window->window, &mask2,
                        &style->bg[GTK_STATE_NORMAL], back2_xpm);
(the program has now seg faulted)

Is that how you use gdk_pixmap_new? I've invented the '16' but it seemed
to work... I don't understand what is supposed to go there. What is depth?


Travis Loyd
[email: lelandg@usa.net				Encrypt your email too: ]
[other: s201635@mail.nwmissouri.edu		     http://www.pgp.com	]
[  pgp: send email with subject: sendmepgp				]
#include <gtk/gtk.h>
#include "elements.h"

void view_board(gchar *boardname) {
	GtkWidget *main_window;
	GtkWidget *final_image;
	GdkPixmap *the_board;
	GdkPixmap *new_element;
	GdkBitmap *mask1;
	GdkBitmap *mask2;
	GtkStyle *style;
	GdkGC *gc;
	gint x, y;

	g_print("Viewing %s ...\n", boardname);

	main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_signal_connect(GTK_OBJECT(main_window), "delete_event",
			GTK_SIGNAL_FUNC(gtk_exit), NULL);
	gtk_signal_connect(GTK_OBJECT(main_window), "destroy",
			GTK_SIGNAL_FUNC(gtk_exit), NULL);

	gtk_widget_realize(main_window);

	/* Create the actual board */
	the_board = gdk_pixmap_new(
			main_window->window, 480, 480, 16);

g_print("1\n");
	/* Load up an element */
	new_element = gdk_pixmap_create_from_xpm_d(
			main_window->window, &mask2,
			&style->bg[GTK_STATE_NORMAL], back2_xpm);

g_print("1.5\n");
	gc = gdk_gc_new(new_element);
	gdk_gc_set_clip_mask(gc, mask2);

g_print("2\n");
	/* Combine 2 images here */

	for(y = 0; y < 12; y++) {
		for(x = 0; x < 12; x++) {
			gdk_gc_set_clip_origin(gc, (x*40), (y*40));
			gdk_draw_pixmap(the_board, gc, new_element, 0, 0, (x*40), (y*40), 40, 40);
		}
	}

g_print("3\n");
	/* Put image to a final_image */

	final_image = gtk_pixmap_new(the_board, mask1);

	gtk_widget_show(final_image);

g_print("4\n");
	gtk_container_add(GTK_CONTAINER(main_window), final_image);

	gtk_widget_show(main_window);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]