Toggle reference problem



Hi all, 
I am trying to use toggle reference, but when I remove toggle refence
from GtkWindow I get those errors:

(<unknown>:7228): GLib-GObject-WARNING **: instance with invalid (NULL)
class pointer
(<unknown>:7228): GLib-GObject-CRITICAL **: g_signal_handlers_destroy:
assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(<unknown>:7228): GLib-GObject-WARNING **: instance with invalid (NULL)
class pointer
(<unknown>:7228): GLib-GObject-CRITICAL **: g_signal_handlers_destroy:
assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

I observe this behavior only on GtkWindow, other widgets are ok.

What do I wrong?

Thank you,
Stanislav Bohm

Demonstration code:

#include <gtk/gtk.h>

gboolean delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
{
	gtk_main_quit();
	return TRUE;
}

void notify(gpointer g, GObject *obj, gboolean is_last)
{
}

void init(GObject *obj)
{
	g_object_add_toggle_ref(obj,notify, NULL);
	g_object_unref(obj);
}

void clean(GObject *obj)
{
	printf("---> ref_count: %i\n ",obj->ref_count);
	g_object_remove_toggle_ref(obj,notify, NULL);
	printf("---> ref_count: %i\n ",obj->ref_count);
}

int main()
{
	gtk_init(0, NULL);
	GtkWidget *win = gtk_window_new(0);
	init(G_OBJECT(win));
	gtk_widget_show_all(win);

	g_signal_connect(G_OBJECT(win), 
		"delete_event", G_CALLBACK(delete_event), NULL);

	gtk_main();

	clean(G_OBJECT(win));
	return 0;
}



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