I’m trying to manually create a GListStore, by using my own row structure, by trying to do what Emanuelle says in How to use GListStore by creating my own “GObject” object
I think I did what it was said in the GObject tutorial GObject – 2.0: GObject Tutorial, everything was fine, until when I tried to do:
GListStore *root = g_list_store_new(MODELE_VIEWER_TYPE_DATA);
ModeleViewerData * g1 = g_object_new (MODELE_VIEWER_TYPE_DATA, NULL);
I go this error on the last instruction: “g_object_ref: assertion ‘!object_already_finalized’ failed”.
I checked “G_OBJECT(g1)->ref_count” and it gives me 0, so I guess it was the reaon of this error after I checked the source code of GObject.c
I tried to trick it by calling “g_object_ref(g1)” just before, by hoping that it will increase to “1” but I have same error" g_object_ref: assertion ‘!object_already_finalized’ failed"
In my “.h” file:
#define MODELE_VIEWER_TYPE_DATA (modele_viewer_data_get_type ())
G_DECLARE_FINAL_TYPE (ModeleViewerData, modele_viewer_data, MODELE_VIEWER, DATA, GObject)
ModeleViewerData *modele_viewer_data_new (const char * col1, const char * col2, const char * col3, const char * col4);
in my .c file
/* Class virtual function fields. */ void (* open) (ModeleViewerData *modeleViewerData, GError **error); /* Padding to allow adding up to 12 new virtual functions without * breaking ABI. */ gpointer padding;
G_DEFINE_FINAL_TYPE (ModeleViewerData, modele_viewer_data, G_TYPE_OBJECT)
modele_viewer_data_new (const char * col1, const char * col2, const char * col3, const char * col4)
return g_object_new (MODELE_VIEWER_TYPE_DATA,
modele_viewer_data_init (ModeleViewerData *self)
g_print(“modele_viewer_data_init IN… \n”);
/* self->column1 = g_alloca0(50); self->column2 = g_alloca0(50); self->column3 = g_alloca0(50); self->column4 = g_alloca0(50); */ // GObjectClass *mvdClass = G_OBJECT_CLASS (modele_viewer_data_parent_class); //ref_count_init(G_OBJECT(self)->ref_count); // g_ref_count_init(G_OBJECT(self)->ref_count);
I also have the following functions implemented:
Do you know why it doesn’t want to put ref_count to 1 ?
I spent all my nights for many days to figure out what’s wrong, and I don’t find any example on internet, but I’m tired now, so I need your help.