RE: (gtk_pixmap_new): assertion `val != NULL' failed
- From: "Ronald Bultje" <rbultje ronald bitfreak net>
- To: "Lars Hallberg" <lah micropp se>
- Cc: <gtk-list gnome org>
- Subject: RE: (gtk_pixmap_new): assertion `val != NULL' failed
- Date: Thu, 7 Jun 2001 16:03:16 +0200
Hi again,
mr. stupid was playing in my head again.
>> #include "image.xpm"
>> void create_pixmap(GtkWidget *w) {
>> GdkPixmap *pixmap;
>> GdkBitmap *mask;
>> pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
>> gtk_widget_get_default_colormap(),
>> &mask, NULL, (gchar **)image_xpm);
>> w = gtk_pixmap_new (pixmap, mask);
>> }
>> void test() {
>> GtkWidget *w = NULL;
>> create_pixmap(w);
>> if (w == NULL) g_print("I am stupid\n");
>> else g_print("I am not that stupid\n");
>> }
>> ---
>>
>> Should return "I am not that stupid", right? (I don't have a xwindows
>> computer on my hands here so I can't test it - grom).
>
>unless create_pixmap(w) is C++ with an referens argument this program
>*will* output "I am stupid\n". In C, ther is *no* way the
>create_pixmap
>funktion can change its argument. It can change the memory the pointer
>points to (but then it have to be pointing to valid memory, not NULL),
>but it can *not* change the pointer itself. So, i C, w is garanteed
>to still point to NULL! You actuly have to send a pointer to a pointer
>for the funktion to be able to change the pointer.
Double oops. I forgot that. Let's try this one then:
#include "image.xpm"
void create_pixmap(GtkWidget **w) {
GdkPixmap *pixmap;
GdkBitmap *mask;
pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
gtk_widget_get_default_colormap(),
&mask, NULL, (gchar **)image_xpm);
*w = gtk_pixmap_new (pixmap, mask);
}
void test() {
GtkWidget *w = NULL;
create_pixmap(&w);
if (w == NULL) g_print("I am stupid\n");
else g_print("I am not that stupid\n");
}
This better? :-)
Stupid me...
Regards,
Ronald
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]