gtk_main_quit() as button callback?
- Date: Wed, 22 Jul 2015 17:09:36 -0500
- From: richard boaz <ivor.boaz@xxxxxxxxx>
- Subject: gtk_main_quit() as button callback?
I'm in the process of converting my app from v2 to v3 and have come across something strange:
Attaching gtk_main_quit() to a button's click callback does not result in the application quitting.
What I see:
- attaching gtk_main_quit() to the to the top window destroy signal works fine, i.e., quit the app using the WM 'x'
- attaching gtk_main_quit() to a button does not work:
2.1) first click - nothing happens
2.2) each subsequent click - warning message is written to the cmd line:
gtk_main_quit: assertion 'main_loops != NULL' failed
- gdb tells me that gtk_main_quit() is correctly invoked on the button click
- I will also deduce from the warning message that the main loop is actually gone after the first click
So why does gtk_main() not return?
This worked as expected in GTK2.
The following minimal program (top window + quit button) demonstrates this strangeness. Could this be platform-specific somehow? (Ubuntu 14.04)
any insights appreciated,
== quit button example ==
// save to quit.c
// gcc quit.c `pkg-config --cflags --libs gtk+-3.0` -g -o quit-button
static void activate(GtkApplication *app, gpointer nil)
GtkWidget *topWindow, *button;
topWindow = gtk_application_window_new(app);
g_signal_connect(topWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL);
button = gtk_button_new_with_label("QUIT");
g_signal_connect(button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_resize(GTK_WINDOW(topWindow), 300, 350);
int main(int argc, char **argv)
int status = 0;
app = gtk_application_new("quit.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list
- Prev by Date: A question about gdbus using ipv6 link local address
- Next by Date: Re: gtk_main_quit() as button callback?
- Previous by thread: A question about gdbus using ipv6 link local address
- Next by thread: Re: gtk_main_quit() as button callback?