> As I understand it string = g_strdup_printf(... produces a copy and > points string towards that copy, the adress of the copy is then > passed on by g_signal_connect as the data pointer, hence freeing > string destroys the string and should not be done (and doing it > produces random output in the print_button callback).
Plenty of people suggested using a weak reference to free the string data. But since the string is attached to the signal, why not let the signal clean up the string itself? gulong g_signal_connect_data (gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags); I haven't actually needed to do something like that myself, but it's sitting there in the APIs just waiting for someone to use it! According to the API's, the GClosureNotify receives your data as its one and only argument, which makes it a perfect place to stick g_free(). Fredderic _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list