maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Strange behaviour from gtk_widget_destroy (https://talk.maemo.org/showthread.php?t=61070)

benbrown 2010-08-25 17:37

Strange behaviour from gtk_widget_destroy
 
I'm writing a fairly simple countdown timer app, and am destroying a vbox with a couple of hboxes with buttons and labels in.

It's early days yet so I've just been running it in scratchbox x86.

If I click on my delete button, it calls gtk_widget_destroy on the box fine, and disappears as I'd expect it to. On the console there are no errors.

However, if I then move the mouse pointer over the title bar or the close icon, or the notification area, I get this message instantly on the console:

Code:

bbtimer[8559]: GLIB CRITICAL ** GLib-GObject - g_object_ref: assertion `G_IS_OBJECT (object)' failed
bbtimer[8559]: GLIB CRITICAL ** GLib-GObject - g_object_ref: assertion `G_IS_OBJECT (object)' failed

Everything else seems to be fine afterwards. If I just run gtk_widget_hide instead it doesn't produce this error.

Any ideas? I'm still pretty new at this GTK thing but getting a bit better at it (I think...)

dannym 2010-08-26 13:18

Re: Strange behaviour from gtk_widget_destroy
 
Is the button within that vbox?
Hard to say...
Why call gtk_widget_destroy manually at all? What are you trying to do?

benbrown 2010-08-26 15:45

Re: Strange behaviour from gtk_widget_destroy
 
I want the application to have multiple, independent timers. The vbox holds the gui elements for one of these timers, including several buttons (Start/Stop, Reset and Delete). It'd be good to be able to remove timers when you don't want them any more so I added the delete button which runs the gtk_widget_destroy when clicked.

dannym 2010-09-13 09:25

Re: Strange behaviour from gtk_widget_destroy
 
I don't know, maybe you messed up something with the refcounting or it is a bug in the maemo version of gtk? Code? :-)

I tried the worst possible scenario and that works:

#include <gtk/gtk.h>

static void delete_box(GtkButton* button_1, GtkBox* box) {
gtk_widget_destroy(box);
}

int main(int argc, char* argv[]) {
GtkWindow* window;
GtkVBox* box_1;
GtkButton* button_1;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
box_1 = gtk_vbox_new(TRUE, 1);
button_1 = gtk_button_new_with_label("Foo");
g_signal_connect(button_1, "clicked", delete_box, box_1);
gtk_box_pack_start(box_1, button_1, FALSE, FALSE, 0);
gtk_container_add(window, box_1);
gtk_widget_show_all(window);
gtk_main();
return 0;
}

Venemo 2010-09-13 09:34

Re: Strange behaviour from gtk_widget_destroy
 
Quote:

Originally Posted by benbrown (Post 798115)
...

We need to see your code before we can help.


All times are GMT. The time now is 23:13.

vBulletin® Version 3.8.8