Unref-ing a dummy GtkWindow -> crash



I'm trying implementing dynamic object creation for a language binding.
First of all, I need to be able to simply create objects without specifying
attributes, and free them.

This seems this works for some types (GtkAction) but not for
others (GtkWindow).

int main (int argc, char *argv[]){
    gtk_init (&argc, &argv);
    gpointer x = g_object_newv(GTK_TYPE_ACTION, 0, NULL);
    g_object_unref(x);
    gpointer y = g_object_newv(GTK_TYPE_WINDOW, 0, NULL);
    g_object_unref(y);
/***
GLib-GObject-WARNING **: invalid unclassed pointer in cast to GtkObject
GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
GLib-GObject-CRITICAL **: file gsignal.c: line 1767:
  assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
Access violation reading location 0xaaaaaaac
***/
    ...
}

Same happens with gtk_widget_new and gtk_window_new

Is it not possible to create a GtkWindow object and trash it right
away, or am I doing it the wrong way?




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