Re: (gtk_pixmap_new): assertion `val != NULL' failed

On Thu, Jun 07, 2001 at 01:52:56PM +0200, Ignacio Nodal wrote:
> Helmethead wrote:
> >Sigh :)
> hehehe, be patient with me :)))

No worries, I have nothing else to do ;)

> >
> > Have you ever tried doing this when you were learning C: 
> > void foo (int i)
> > {
> >    i = 10;
> >    printf ("%d\n", i);
> > } int main ()
> > {
> >    int a = 5;     printf ("%d\n", a);
> >    foo (a);
> >    printf ("%d\n", a);
> >    return 0;
> > }

> Yeah, but.. gboolean ParameterKernel::ReadPixmap(gchar **pixstring,
> GdkPixmap *pix) is more like void foo(int* i), or not? Well, I suppose
> not, since then my program would be working fine :)))

Nope, it's like foo(int i)
ParameterKernel::ReadPixmap(gchar **pixstring, GdkPixmap*& pix) is like foo(int &i)
you can use a GdkPixmap ** if you really want it to be like foo(int *i) :)

> The program crahsed on the line I said, because it printed "The program
> arrives this point\n" and then returned me the segmentation fault, not
> printing "Segmentation fault is in the line above\n".

Hmm... gdk_pixmap_colormap_create_from_xpm_d must be failing (as well!)
Write a g_print that prints out the value of pixmap and see if it's NULL

> [...]
>   g_print("The program arrives this point\n");
>   pix =  *pixmap;
>   g_print("Segmentation fault is in the line above\n");
> [...]
> When I use Ronald's proposal it doesn't return me any segmentation fault
> (both g_prints are shown) but then, when using gtk_pixmap_new() out from
> the ReadPixmap() function I get the "assertion `val != NULL' failed"
> error mentioned in my previous mail...

The variable passed to ReadPixmap isn't getting set, though if I'm right about what I said above it'd be set to NULL anyway. :(

> Is there anyway to use my GdkPixmap* _pixmap as a parameter for
> gtk_pixmap_new(), outside from the function where I create it using
> gdk_pixmap_colormap_create_from_xpm_d()??? really, anyway... 

With exactly one change, change the function declarations from

ParameterKernel::ReadPixmap (gchar **pixstring, GdkPixmap* pix)
ParameterKernel::ReadPixmap (gchar **pixstring, GdkPixmap*& pix)

and it will automagically set the variable you pass in properly. C++ references are pretty cute.

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