On Tue, 23 Dec 2008 04:42:09 +0300, [email protected] <[email protected]> wrote:

I followed the step of Richard's guide, everything run well, but I can
not exit from the callback of g_idle_add correctly. Why?


From gnome help:

"Idles, timeouts, and input functions from GLib, such as g_idle_add(), are executed outside of the main GTK+ lock. So, if you need to call GTK+ inside of such a callback, you must surround the callback with a gdk_threads_enter()/gdk_threads_leave() pair or use gdk_threads_add_idle_full() which does this for you"

Proof link: http://library.gnome.org/devel/gdk/stable/gdk-Threads.html

So i think you should try so:

static gboolean Result (gpointer data)
{
        gint param = (gint)data;
        gdk_threads_enter();
        GtkWidget* pDialog = gtk_message_dialog_new(GTK_WINDOW(win),
                GTK_DIALOG_MODAL,
                GTK_MESSAGE_INFO,
                GTK_BUTTONS_OK,
                "The thread result: %d ",
                param);
        gtk_dialog_run(GTK_DIALOG(pDialog));
        gtk_widget_destroy(pDialog);
        gdk_threads_leave();
        return FALSE;
}

--
Vyacheslav D.
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to