On Tuesday 05 July 2011 14:24:48 Herbert Gasiorowski wrote:
> I have an issue with nearly all gtk+ programs: since about one week the 
> programs 
> crash at startup with some fault like this:
> 
> *** glibc detected *** ./gtk-tab2: munmap_chunk(): invalid pointer: 
> 0x0000000001aa8eb0 ***
> ======= Backtrace: =========
> /lib64/libc.so.6[0x365a47703a]
> /lib64/libglib-2.0.so.0(g_free+0x23)[0x365c449743]
> 
> But if I start the program via ssh it runs as expected:
>     ssh -X $HOSTNAME myprogram
> AND if I link without -lmcheck it is ok too ...
> 
> I deleted all code which did not affect this issue:
> It is not much more than another Hello World example but using gtk_entry to 
> display the text (#if 1):
> 
> Fedora 15 and gtk3-3.0.11-1.fc15.x86_64
> (gtk2 will fail too)
> 
> Can someone tell me what I should do next?
> 
> ==================================================================================
> /* test with
>   *  gcc -Wall -g -o gtk-tab gtk-tab.c -lmcheck `pkg-config --cflags --libs 
> gtk+-3.0` && ./gtk-tab
>   */
> 
> #include <stdlib.h>
> #include <string.h>
> #include <gtk/gtk.h>
> 
> #define SUMMARY "gtk test"
> #define TRACE(l,fmt,args...) fprintf(stderr,"#%03d#%9.9s:%3d# " 
> fmt"\n",l,__FILE__,__LINE__,##args)
> 
> int main( int argc, char **argv ) {
>       GtkWidget *window;
>       GtkWidget *value;
>       TRACE(9,"gtk init");
>       gtk_init (&argc, &argv);
> 
>       TRACE(12,"gtk create a new window");
>       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>       gtk_window_set_title (GTK_WINDOW (window), SUMMARY);
>       g_signal_connect (G_OBJECT (window), "destroy",
>                       G_CALLBACK (gtk_main_quit), NULL);
>       
>       TRACE(12,"Create the text");
> #if 1
>       value = gtk_entry_new();
>       gtk_entry_set_text( GTK_ENTRY(value), "test 123" );
> #else
>       value = gtk_label_new("test 123");
> #endif
> 
>       gtk_container_add (GTK_CONTAINER (window), value);
> 
>       TRACE(12,"gtk show all");
>       gtk_widget_show_all (window);
>       TRACE(11,"gtk loop: start");
>       gtk_main ();
>       TRACE(11,"gtk loop: done");
>       return 0;
> }
> ==================================================================================

I in the past used this function this insert text in entry widgets, don't know 
if it helps in your case:

void my_gtk_entry_set_text(GtkEntry *entry, char *data)
{
        char *tmp;

        if (!data) data = "";

        if (g_utf8_validate(data, -1, NULL) != TRUE) {
                tmp = g_locale_to_utf8(data, -1, NULL, NULL, NULL); 
                gtk_entry_set_text(entry, tmp);
                xfree(&tmp);
        } else {
                gtk_entry_set_text(entry, data);
        }
}

Hope this helps.

ZZ
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to