I bet i have some kind of memory problem here; not sure what the origin is. I have a GUI that has three images side by side. When i press a button to load in a new image, it creates a detached pthread and puts that image into image box 1; before that, the image from box 1 went to box 2, and that of 2 went into image box 3 (and the image in box 3 is discarded).
The thing is that i can load in an image perfectly fine, but when moving the images from box 2 to 3 and 1 to 2 things go bad. The images are corrupted, they just look like colorful static 'snow'.
What i do: i define the three boxes outside of the main-loop
Then inside of the main-loop i create that pthread, where i create 3 dummy images first:
gtk_image_new_from_pixbuf (... etc)
From the pthread i load the new image somehwere and i go into this:
//First put 2 in 3, then 1 in 2. Then update 1.
gtk_image_set_from_pixbuf( GTK_IMAGE(guiImage3), gtk_image_get_pixbuf( GTK_IMAGE(guiImage2) ) );
gtk_image_set_from_pixbuf( GTK_IMAGE(guiImage2), gtk_image_get_pixbuf( GTK_IMAGE(guiImage1) ) );
gtk_image_set_from_pixbuf( GTK_IMAGE(guiImage1), MatToPixbuf(matGUI) );
After this, the pthread ends nicely, and i can repeat the process.
Now what always happens is that the first image box displays the image fine, but the 2nd and 3rd are corrupted, as i said earlier. What is happening here? Should i allocate the pixbuf's 'globally' as well?
[Using GTK-2.? in C++]