GTK deadlock in gtk_main
Hi all, I am not sure if this is a bug or just my misunderstanding of how the synchronization is done in GTK. Below is a simple test.c example in which the deadlock occurs. Basically program deadlocks itself when idle_func is done and control is returned to gtk_main. Thanks for your help in advance, Tomas #include stdlib.h #include glib.h #include gtk/gtk.h #include gdk/gdk.h static GStaticMutex customMutex = G_STATIC_MUTEX_INIT; static void custom_enter (void) { g_print (LOCK\n); g_static_mutex_lock (customMutex); } static void custom_leave (void) { g_static_mutex_unlock (customMutex); g_print (UNLOCK\n); } static gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { gtk_widget_destroy (widget); gtk_main_quit (); return TRUE; } static gboolean idle_func (gpointer user_data) { /* Do something */ g_print (IDLE start\n); gtk_main_iteration_do (FALSE); g_print (IDLE end\n); return FALSE; } int main (int argc, char *argv[]) { GtkWidget *window; gdk_threads_set_lock_functions (custom_enter, custom_leave); g_thread_init (NULL); gdk_threads_init (); gdk_threads_enter (); gtk_init (argc, argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT(window), delete-event, G_CALLBACK(on_delete_event), NULL); g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, idle_func, NULL, NULL); gtk_widget_show (window); gtk_main (); gdk_threads_leave (); return EXIT_SUCCESS; } compile command: gcc test.c -o gtkTest `pkg-config --cflags --libs gtk+-2.0` LINUX dist.: Fedora 13 GTK version: 2.20.1 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK deadlock in gtk_main
Hi, So what you suggest is to have gdk_threads_enter and gdk_threads_leave at the beginning and at the end of the idle function? Is this really intended? Anyway, thanks for your help. Regards, Tomas Hi. You're having troubles because gtk_main_iteration_do() does it's own unlock/lock cycle. When your idle callback is executed, your mutex is unlocked. gtk_main_iteration_do() unlocks it again, executes whatever is there to be executed and locks it. Now control returns back to main loop, which tries to lock mutex and here you have your lock. Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GdkPixbuf animation
Hi all, I have noticed that there is a way to load an animation using gdk_pixbuf_animation_new_from_file. But is there a way to save already loaded/created animation to a file? For example GdkPixbuf has a method gdk_pixbuf_save Thanks in advance, Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: setlocale gtk
I forgot to write that this behaviour apply only on Windows not on Linux. Cheers Tomas Soltys Hi all, Recently I have ran into a problem with locale settings. 1. I need my application to have disabled locale settings. This is mainly for the number representation. 2. If I call gtk_disable_setlocale () then I will not get a modification time and date in a filechooser dialog. Is there a way how to get around this? Thanks Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
setlocale gtk
Hi all, Recently I have ran into a problem with locale settings. 1. I need my application to have disabled locale settings. This is mainly for the number representation. 2. If I call gtk_disable_setlocale () then I will not get a modification time and date in a filechooser dialog. Is there a way how to get around this? Thanks Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Embed theme with a gtk app?
Yes there is a way. Here is how I have done it. gchar *rc_files[] = { path to your rc file, NULL}; gtk_rc_set_default_files (rc_files); Regards, Tomas Soltys Is there any way to either embed or make a gtk program load a theme that comes with the program, without the user having to install anything else. I have some programs mainly for windows that look like absolute rubbish when on the default theme, but alot of my users on the windows version have the DLL's all over the place. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
WIN32: Spawning a command-line process
Hi, I am writing a GUI application which executes a command-line executable and reads its output from stdout. For this I am using function g_spawn_async_with_pipes. If command-line program is linked with -mswindows then everything works fine, but I can not execute prog in command line. Stdout is lost. So -mswindows is not an option. Does anybody have an idea how to solve this problem? Thanks. Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: An 'oldie' question... GtkCList anyone?
Hi, try to declare str as: char *str[4]; Regards, Tomas Hello people. In the process of converting an old program from mSQL to MySQL, I found a couple of potential traps and optimized a couple of functions. I now have a problem with adding lines into a GtkCList using gtk_clist_append. The code is like this: char *bff, str[4]; bff = strdup(abc|def|ghi|etc); Just to show bff has to freed later splitline(bff, str); This puts pointers into str to each of the substrings (at the start and after each |, converting them to \0 ) gtk_clist_append(clist, str); Add the line, g_free(bff); It looks as if the g_free happens before the append, because gibberish appears on the screen. Is there a way to assure the append is finished before the g_free? John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: An 'oldie' question... GtkCList anyone?
Hi, try to declare str as: char *str[4]; Regards, Tomas Hello people. In the process of converting an old program from mSQL to MySQL, I found a couple of potential traps and optimized a couple of functions. I now have a problem with adding lines into a GtkCList using gtk_clist_append. The code is like this: char *bff, str[4]; bff = strdup(abc|def|ghi|etc); Just to show bff has to freed later splitline(bff, str); This puts pointers into str to each of the substrings (at the start and after each |, converting them to \0 ) gtk_clist_append(clist, str); Add the line, g_free(bff); It looks as if the g_free happens before the append, because gibberish appears on the screen. Is there a way to assure the append is finished before the g_free? John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkFileChooserDialog position
Hi, I have a question about positioning of the file-chooser dialog. The position of the dialog is not correct. I'm using the latest stable version of GTK 2.14.3. The code is compiled on win32. --- CODE -- GtkWidget *dialog; dialog = gtk_file_chooser_dialog_new (Open File, parent_window, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); open_file (filename); g_free (filename); } gtk_widget_destroy (dialog); --- Result is that the dialog is moved towards the lower left corner. It seems to me that the size of the window is not correct. Could it be? Can someone explain me why is this happening. Regards, Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GLib - Spawning Processes
Hi all, I have spent some time trying to create an application that would use GLib to spawn a process. The function I want to use is g_spawn_async_with_pipes. The following code is just simplified version of the real one, but the behavior is the same. On Linux it works but on the Windows it gives following error: - output - Command: C:\Windows\notepad.exe Failed to execute helper program (Invalid argument) Press any key to continue . . . - output - Thanks for help. - spawn.c - #include stdio.h #include stdlib.h #include glib.h static void watch_pid (GPid pid, gint status, gpointer data); static GMainLoop* main_loop; int main (int argc, char *argv[]) { GPid pid; GError *error = NULL; gboolean status; gchar *args[2]; args[0] = g_build_filename (C:, Windows, notepad.exe, NULL); args[1] = NULL; status = g_spawn_async_with_pipes ( NULL, args, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, pid, NULL, NULL, NULL, error); g_print (Command: %s\n, args[0]); if (status == FALSE) { g_print (%s\n, error-message); g_free (args[0]); system(PAUSE); return EXIT_FAILURE; } g_child_watch_add (pid, watch_pid, (gpointer)args[0]); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); g_free (args[0]); system(PAUSE); return EXIT_SUCCESS; } static void watch_pid (GPid pid, gint status, gpointer data) { char *cmd = (char *)data; if (status != 0) { /* error */ g_print (Command \'%s\' failed\n, cmd); } else { /* success */ g_print (Command \'%s\' exited\n, cmd); } g_spawn_close_pid(pid); g_main_loop_quit (main_loop); } - spawn.c - ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
usubscribe
-- This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender immediately and delete this e-mail from your system. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of Ricardo (save for reports and other documentation formally approved and signed for release to the intended recipient). Only Directors or Duly Authorised Officers are authorised to enter into legally binding obligations on behalf of Ricardo unless the obligation is contained within a Ricardo Purchase Order. Ricardo may monitor outgoing and incoming e-mails and other telecommunications on its e-mail and telecommunications systems. By replying to this e-mail you give consent to such monitoring. The recipient should check this e-mail and any attachments for the presence of viruses. Ricardo accepts no liability for any damage caused by any virus transmitted by this e-mail. Ricardo means Ricardo plc and its subsidiary companies. Ricardo plc is a public limited company registered in England with registered number 00222915. The registered office of Ricardo plc is Bridge Works, Shoreham-by Sea, West Sussex, BN43 5FG. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list