[gtkbuilder] when destroyed, the window cannot open again



I wirte a sample application use GktBuilder + glade3. there are one main-window(top level) and some other child-window (top level too, creat and show when the menu item is actived, in my code it is named window_rank).
after close the child-window for first time, i click the menu item again. But this child-window cannot be created and showed again. with many errors or warming like this:

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_append: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_set_text: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_append: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_set_text: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_append: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'

(lsacs_gsecu:11866): Gtk-CRITICAL **: gtk_clist_set_text: assertion `GTK_IS_CLIST (clist)' failed

(lsacs_gsecu:11866): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkCList'


my code is here:

main.c:
#include "gsecu.h"
#define BUILDER_XML_FILE "gsecu.xml"

gboolean init_app (LsacsGsecu *editor);

int main (int argc, char *argv[])
{
LsacsGsecu *gsecu;
gsecu = g_slice_new(LsacsGsecu);
gtk_init (&argc, &argv);
if (init_app (gsecu) == FALSE) return 1; /* error loading UI */
gtk_widget_show(gsecu->window);
gtk_main();
return 0;
}

gboolean init_app (LsacsGsecu *gsecu)
{
GtkBuilder *builder;
GError *err=NULL;

/* use GtkBuilder to build our interface from the XML file */
builder = gtk_builder_new ();
if (gtk_builder_add_from_file (builder, BUILDER_XML_FILE, &err) == 0)
{
error_message (err->message);
g_error_free (err);
return FALSE;
}

/* get the widgets which will be referenced in callbacks */

gsecu->window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));

//初始化安全等级
gsecu->window_rank = GTK_WIDGET (gtk_builder_get_object (builder, "window_rank"));
gsecu->clist_rank = GTK_WIDGET (gtk_builder_get_object (builder, "clist_rank"));
gsecu->entry_rank = GTK_WIDGET (gtk_builder_get_object (builder, "entry_rank"));


/* connect signals, passing our LsacsGsecu struct as user data */
gtk_builder_connect_signals (builder, gsecu);

/* free memory used by GtkBuilder object */
g_object_unref (G_OBJECT (builder));

return TRUE;
}

inittable.c:
void on_initrank_activate (GtkObject *object, LsacsGsecu *gsecu)
{
struct stat filebuf;
gchar *p_space = " ";
int fd,ranknum;
int i;
RANKNAME_SREC rankbuf;
if((fd=open(LSACS_RANKNAME,O_RDWR|O_CREAT|O_APPEND))<0)
{
OK_dialog("读取rankname文件出错", gsecu->window_rank);
return;
}
fstat(fd,&filebuf);
ranknum=(filebuf.st_size/(sizeof(RANKNAME_SREC)));
for(i=1;i<=ranknum;i++)
{
gtk_clist_append(GTK_CLIST(gsecu->clist_rank), &p_space);
lseek(fd,(i-1)*sizeof(RANKNAME_SREC),SEEK_SET);
read(fd,&rankbuf,sizeof(RANKNAME_SREC));
gtk_clist_set_text(GTK_CLIST(gsecu->clist_rank),(i-1),0,rankbuf.rankname);
}
close(fd);
gtk_clist_set_column_width (GTK_CLIST (gsecu->clist_rank), 0, 270);
gtk_widget_show(gsecu->window_rank);
}

i have spended many many time to solve it, can some one help me !



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