Re: g_object_get_data changed data association
- From: "Tristan Van Berkom" <tvb gnome org>
- To: "YU WU" <wuyu_2001 hotmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: g_object_get_data changed data association
- Date: Sat, 26 Jul 2008 01:45:34 -0400
Hi, Check that your list store is properly refcounted, is there any
reason why the list store may have been destroyed previous
to this call ?
Cheers,
-Tristan
On Fri, Jul 25, 2008 at 10:41 AM, YU WU <wuyu_2001 hotmail com> wrote:
dear sir or madam,
i am developing applications with GTK+ and have some problem, following is some digest of my code.
=====================================
store = gtk_list_store_new(NUMS_MAX_FORCE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
g_object_set_data(G_OBJECT(window), "staad_max_force_store", store);
printf("## start store memory=%p\n", g_object_get_data(G_OBJECT(window), "staad_max_force_store"));
printf("## is store=%d\n", GTK_IS_LIST_STORE(store));
printf("## name store=%s\n", G_OBJECT_TYPE_NAME(store));
=====================================
i install a list store by above codes. then i want to update the list store somewhere later.
=====================================
/* for debug */
if(g_object_get_data(G_OBJECT(widget), "staad_max_force_store") == NULL)
printf("NULL\n");
else
{
printf("store memory=%p\n", g_object_get_data(G_OBJECT(widget), "staad_max_force_store"));
printf("## name store=%s\n", G_OBJECT_TYPE_NAME(g_object_get_data(G_OBJECT(widget),
"staad_max_force_store")));
}
while(curr_data)
{
i = 0;
curr_item = curr_data->content;
while(curr_item)
{
gtk_list_store_append(store, &iter);
if(++i == 1)
{
gtk_list_store_set(store, &iter, MAX_FORCE_MEM_NUM, (local1 = char_to_utf8 (curr_data->mem_num)),
MAX_FORCE_ITEM, (local2 = char_to_utf8 (curr_item->item)), MAX_FORCE_FX, (local3 = char_to_utf8
(curr_item->FX)), MAX_FORCE_FY, (local4 = char_to_utf8 (curr_item->FY)), MAX_FORCE_FZ, (local5 =
char_to_utf8 (curr_item->FZ)), MAX_FORCE_MX, (local6 = char_to_utf8 (curr_item->MX)), MAX_FORCE_MY, (local7
= char_to_utf8 (curr_item->MY)), MAX_FORCE_MZ, (local8 = char_to_utf8 (curr_item->MZ)), -1);
g_free(local8);
}
else
gtk_list_store_set(store, &iter, MAX_FORCE_ITEM, (local1 = char_to_utf8 (curr_item->item)),
MAX_FORCE_FX, (local2 = char_to_utf8 (curr_item->FX)), MAX_FORCE_FY, (local3 = char_to_utf8
(curr_item->FY)), MAX_FORCE_FZ, (local4 = char_to_utf8 (curr_item->FZ)), MAX_FORCE_MX, (local5 =
char_to_utf8 (curr_item->MX)), MAX_FORCE_MY, (local6 = char_to_utf8 (curr_item->MY)), MAX_FORCE_MZ, (local7
= char_to_utf8 (curr_item->MZ)), -1);
g_free(local1);
g_free(local2);
g_free(local3);
g_free(local4);
g_free(local5);
g_free(local6);
g_free(local7);
curr_item = curr_item->next;
}
curr_data = curr_data->next;
}
=====================================
after using "g_object_get_data(G_OBJECT(widget), "staad_max_force_store")", i hope to get the store i
defined at the beginning. but in fact i didn't get the list store, but something else -- instead of a list
store. of course, the store can't be updated.
from my debug info, the data gotten from "g_object_get_data(G_OBJECT(widget), "staad_max_force_store")" has
the same memory address with that defined "g_object_set_data(G_OBJECT(window), "staad_max_force_store",
store);", but "G_OBJECT_TYPE_NAME(store)" changed.
so, i would like to know if there is hint to be used for "g_object_get_data" and "g_object_set_data". what
could be the problem?
p.s.: in my program, there is public area -- a gtkbox to be used by all sub-program. if i always run the
above sub-program, the problem mentioned above won't come up. but, if i run the above sub-program first,
then change to another sub-program, and later i come back to the above sub-program, the above problem comes
up. during this process, i used "gtk_widget_destroy" to destroy the widget of the first sub-program in the
public area and build the widget for the next coming sub-program. i am wondering if the
"gtk_widget_destroy" disturbs the data associations table.
i think my question is a little confusing because i could not describe the question clearly enough. i do
hope you could read my words above and try to give me some suggestion. thanks a lot.
looking forward to your reply.
best regards,
wu yu
_________________________________________________________________
Keep your kids safer online with Windows Live Family Safety.
http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_family_safety_072008
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]