more documentation about g_io_add_watch ??



Hi,

I finally found the reason why my GUI freezes while I'm adding file to a rar archive with g_spawn_async_with_pipes. This is what I do

1) Spawn the rar executable with g_spawn_async_with_pipes

2) Create a g_io_add_watch channel this way:
    GIOChannel *ioc;
    ioc = g_io_channel_unix_new ( fd );
    g_io_add_watch (ioc, cond, func, data);
    g_io_channel_set_encoding (ioc, "ISO8859-1", NULL);

3) Then I read the output of the rar executable this way:

gboolean GenOutput (GIOChannel *ioc, GIOCondition cond, gpointer data)
{
        gchar *line = NULL;
        if (cond & (G_IO_IN | G_IO_PRI) )
        {
                while (gtk_events_pending())
                        gtk_main_iteration();
                g_io_channel_read_line ( ioc, &line, NULL, NULL, NULL );
if (line != NULL ) gtk_text_buffer_insert (textbuf, &enditer, line, strlen ( line ) );
        }
        
        else if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
        {
                g_io_channel_shutdown ( ioc,TRUE,NULL );
                g_io_channel_unref (ioc);
                g_spawn_close_pid ( child_pid );
                return FALSE;
        }
        return TRUE;
}

The documentation about g_io_add_wath is very poor, can someone share light on this matter: why g_io_add_watch locks the GUI ?

Thank you,
--
Colossus

Cpsed, a Linux OpenGL 3D scene editor
http://cpsed.sourceforge.net/




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