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

Hiding GtkToolButton problem, Win32 specific behaviour or potential bug ?



Hello,
I've encountered a problem with hiding a GtkToolButton inserted into GtkToolbar. Consider the small program bellow.
When pressing button2, this program freezes. I don't know why this happens - I think the reasons may be two:

1. Using threads on Win32
2. Some bug.

The problem appears when using GTK 2.12.X under Windows and does not appear under Linux (GTK 2.10.X 2.12.X) and also does
not appear when using GTK 2.10.X under Windows. If I remove the threads related code, everything works perfectly on all platforms
with all versions of GTK.

I've also investigated, that the button being hidden must be first in the toolbar and must have the signal connected, in other
case the problem does not appear.

What reason is correct ?

Thanks for ideas



#include <gtk/gtk.h>

GtkWindow *window;
GtkToolButton *button1;
GtkToolButton *button2;
GtkToolbar *toolbar;

void handler1() {
	gtk_widget_hide(GTK_WIDGET(button2));
	
	
}

void handler2() {
	/*CRASH*/
	gtk_widget_hide(GTK_WIDGET(button1));
}

void quitHandler() {
	
	gtk_main_quit();
	
}


int main(int argc,char* argv[]) {
	g_thread_init(NULL);
	gdk_threads_init();
	gdk_threads_enter();
	
	gtk_init(&argc,&argv);
	
	/*Window*/
	window=GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
	
	/*Toolbar*/
	toolbar=GTK_TOOLBAR(gtk_toolbar_new());
	
	/*Buttons*/
	button1=GTK_TOOL_BUTTON(gtk_tool_button_new_from_stock("gtk-add"));
	button2=GTK_TOOL_BUTTON(gtk_tool_button_new_from_stock("gtk-edit"));
	
	gtk_toolbar_insert(toolbar,GTK_TOOL_ITEM(button1),0);
	gtk_toolbar_insert(toolbar,GTK_TOOL_ITEM(button2),1);
	
	gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(toolbar));
	
	/*Show all*/
	gtk_widget_show_all(GTK_WIDGET(window));
	gtk_widget_show(GTK_WIDGET(window));
	
	g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(handler1),NULL);
	g_signal_connect(G_OBJECT(button2),"clicked",G_CALLBACK(handler2),NULL);
	g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(quitHandler),NULL);
	
	gtk_main();
	
	gdk_threads_leave();
}






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