After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 155038 - Bug when using gdk_threads_enter and gdk_threads_leave
Bug when using gdk_threads_enter and gdk_threads_leave
Status: RESOLVED DUPLICATE of bug 60620
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.4.x
Other All
: Normal blocker
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-10-10 18:52 UTC by Nicolas [Koxon]
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Nicolas [Koxon] 2004-10-10 18:52:58 UTC
Please describe the problem:
When i use these functions the application freeze and after no actions are possible.
On Linux it works well but on Windows there is this problem.


Steps to reproduce:
1. 
2. 
3. 


Actual results:


Expected results:


Does this happen every time?
On windows yes this happen every time

Other information:
An exemple to show you the problème try it on Windows with Visual or DevC++. 
It shows a dialog box which is created in another thread :

#include <stdlib.h>
#include <gtk/gtk.h>
#include <windows.h>

/* Dialog message */
void msg(GtkWidget *window){
	GtkWidget *dialog;
	
	gdk_flush();
	gdk_threads_enter();
	dialog = gtk_message_dialog_new (GTK_WINDOW(window),
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_INFO,
			GTK_BUTTONS_OK,
			"OK");
	gtk_dialog_run (GTK_DIALOG (dialog));
	gtk_widget_destroy (dialog);
	gdk_threads_leave();
}

/* test thread */
void *test(void *data){

	/* Do something ... */
	
	/* Shows final info */
    msg(data);
	
    return(NULL);
}

/* test callback */
void test_callback(GtkButton *button, GtkWidget *window){
    g_thread_create(test, window, FALSE, NULL);
}

/* window with 2 buttons */
GtkWidget *create_window(){
    GtkWidget *window, *button1, *button2, *hbuttonbox;
    
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);   
    g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), 
window);
    
    hbuttonbox = gtk_hbutton_box_new();
    gtk_widget_show(hbuttonbox);
    gtk_container_add (GTK_CONTAINER (window), hbuttonbox);
    
    button1 = gtk_button_new_from_stock ("gtk-quit");
	gtk_widget_show (button1);
	gtk_container_add (GTK_CONTAINER (hbuttonbox), button1);
	g_signal_connect(GTK_OBJECT(button1), "clicked", G_CALLBACK(gtk_main_quit), 
NULL);
	
	button2 = gtk_button_new_with_label("test");
	gtk_widget_show(button2);
	gtk_container_add(GTK_CONTAINER(hbuttonbox), button2);
	g_signal_connect(GTK_OBJECT(button2), "clicked", G_CALLBACK(test_callback), 
window);
	
	return(window);
}

int main(int argc, char **argv){
    GtkWidget *window;

	/* Inicia o gtk*/
	g_thread_init(NULL);
	gdk_threads_init();
	gtk_init (&argc, &argv);
	
	window = create_window();
	
	gtk_widget_show(window);
	
	gdk_threads_enter();
	gtk_main ();
	gdk_threads_leave();

    return 0;
}
Comment 1 Tor Lillqvist 2004-10-10 19:49:10 UTC
GTK on Windows doesn't work if used from multiple threads.
Comment 2 Tor Lillqvist 2004-10-10 19:57:02 UTC

*** This bug has been marked as a duplicate of 60620 ***